This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Maybe a bug?


Hi,
	I wanted to reported a bug...if you agree it is a bug...here is the problem:

I am using the following version of gcc:

[qidwai@parilia Utils]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

on Redhat 6.2


I have a header file containing the following code (please ignore the line 
numbers in the compiler warning/error report as I have taken out a lot junk 
code for our purposes):

#ifndef _MQ_OUTPUT_HANDLER_STDERR_
#define _MQ_OUTPUT_HANDLER_STDERR_

#ifdef __cplusplus
extern "C" {
#endif

   //Misbah Qidwai's Utilities Library namespace.
   namespace MQ_UTILS
   {
    unsigned int W_LineNum;
    char *pW_FileName=NULL;
   }
   //End of namespace

#ifdef __cplusplus
}
#endif

   #define NADS_WarningMSG(s)\
     MQ_UTILS::pW_FileName=__FILE__; MQ_UTILS::W_LineNum=__LINE__;\
     MQ_UTILS::NADS_WarningMSGPrint s

//Misbah Qidwai's Utilities Library namespace.
namespace MQ_UTILS
{
   void NADS_WarningMSGPrint(const char *_pFormat,...);
}
//End of namespace

#endif

The output I get when I compile this code is:

CC -c  -DMQ_LINUX -DMQ_DEBUG -g3     -ansi  output_handlers.cpp
In file included from output_handlers.cpp:71:
output_handlers.h:63: warning: ANSI C++ forbids declaration `pW_FileName' 
with no type
output_handlers.h:63: conflicting types for `int pW_FileName'
output_handlers.cpp:47: previous declaration as `char * pW_FileName'
output_handlers.h:63: warning: initialization to `int' from `char *' lacks 
a cast
output_handlers.h:63: warning: ANSI C++ forbids declaration `W_LineNum' 
with no type
output_handlers.h:63: conflicting types for `int W_LineNum'
output_handlers.cpp:46: previous declaration as `unsigned int W_LineNum'
output_handlers.h:63: stray '\' in program
output_handlers.h:74: syntax error before `MQ_UTILS'

Problem 1:
	As you can pW_FileName and W_LineNum are both declared however the 
compiler is giving a warning message on this....I don't why that is...any 
clues?

Problem 2:
	It appears the compiler halts on the second namespace block and reports a 
syntax error.

The interesting thing is that I am able to compile this code on other 
platforms...so I don't know if I am breaking any rules...not that I think I 
am...but what do you think?  I think it is a bug...

Thanks!

Misbah
_________________________________________
Misbah Qidwai
R & D Project Leader
Modeling and Simulation Technology Branch
National Advanced Driving Simulator
and Simulation Center (NADS-SC)
2401 Oakdale Blvd.
Iowa City, Iowa 52242-5003
Tel: (319)335-4646  FAX: (319)335-4658
Email:qidwai@nads-sc.uiowa.edu
http://soli.inav.net/~misbah


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]