0

One of my users is getting an error message when trying to compile a C part of our mixed C/C++ codebase on ubuntu 12.04 with gcc 4.8.1

We have a library in C++ with some C-linkage functions in, and want to compile a C program linking to it. The library is compiled with g++ and builds fine. The c program fails like this:

> gcc -O3 -g -fPIC -I/media/Repo/lcdm/code/cosmosis/ -Wall -Wextra -pedantic -Werror -std=c99 -o c_datablock_t c_datablock_test.c -L . -lcosmosis

cc1plus: error: command line option ‘-std=c99’ is valid for C/ObjC but not for C++ [-Werror]

The program has a lower case .c file suffix, so why does gcc try to compile it as c++ ? We have not seen this on other OSes.

(I know we could kick the problem down the road by removing -Werror or handle this particular file with -x c but I'd like to solve the real problem.)

JoeZuntz
  • 1,092
  • 10
  • 16

2 Answers2

0

why does gcc try to compile it as c++

I can think of only two plausible explanations, and they both are end-user's fault.

  • It could be that the user transferred sources via Windows, and the file is really called C_DATABLOCK_TEST.C, and the user is misleading you.
  • It could also be that the user overwrote his gcc with g++ (surprisingly many people believe that gcc and g++ are the same thing, but they are not).

To disprove the first possibility, ask the user to execute his build commands under script, and send you resulting typescript.

To disprove the second, ask the user to add -v to the compile command.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
-1

This look like GCC Bug 54641, which has been fixed in a later release of GCC. It is only a warning, but your compile flags are causing GCC to treat all warnings as errors.

Tim M.
  • 11
  • 1