www.delorie.com/djgpp/faq/dev-probs/borland-ok.html   search  
Gcc doesn't understand // comments

My C program compiles OK with Borland's C, but gcc complains about "parse error before `/'" at a line where I have a ``//''-style comment.

That's because // isn't a comment in neither ANSI C nor in K&R C. Borland and Microsoft C compilers support it as an extension. You've just learned it's a bad practice to use this extension in a portable program. If it's a C++ program, then rename it to have a suffix which will cause gcc to compile it as such, or use ``-x c++' switch. If it's a C program, but you want to compile it as C++ anyway, try ``-x c++''; it can help, but can also get you in more trouble, because C++ has its own rules. You can also use ``-lang-c-c++-comments'' preprocessor switch, but that requires to run cpp separately, as gcc doesn't accept the -lang-XXX switches on its command line. It's best to change those comments to C-style ones, if you really mean to write a C program.

  webmaster     delorie software   privacy  
  Copyright © 1995     Updated Feb 1995