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]

Re: Macro does not compile


clive@emultek.co.il writes:
> 
> 
> 
> The compilation results for this Macro are shown after it.
> #define DECLARE_CLASS(n)                                       \
> class MyClass##n                                 \
> {                                                              \
> public:                                                        \
>  MyClass##n (int i);                                       \
>  ~MyClass##n (void);                                             \
> private:                                                       \
>  char *_dum;                                              \
> };
> DECLARE_CLASS(10)
> 
[ ... ]
> In file included from test.cpp:1:
> test.h:3: parse error before `#'
> test.h:3: stray '\' in program

I'd bet that the source file is in DOS format (ie., it has '\r\n' line
endings instead of '\n'), and that's what's causing the problem. To
check, do the following:
  
  $ od -c test.cpp | less

if you see '\r' there, that's your problem. If so, use recode or some
such program (or, in vim, do a ``:set ff=unix'' and then write it out)
to get rid of the '\r' and you should be set.

Regards,
Mumit


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