User forums > Help

C compiling as C++

(1/1)

AndrewVinci:
Hello all, just having a basic problem with CB, any help is much appreciated.

(Running : WinXP Pro 32bit, MinGW 3.4.2, CB Nightly ( August 14 ) )

I am currently just trying to test out CB, and compile some basic program, however it is not working.
Error : warning: command line option "-std=c99" is valid for C/ObjC but not for C++

The file is called 'file.c' and is written in correct C (as far as syntax goes) as tested on other computers (not with CB, just with command line GCC). This is a source file, not a project, and was created as a 'C/C++ source' file from the 'new' menu.

After changing the toolchain line for 'C++ Compiler' from 'mingw32-g++.exe' to 'mingw32-gcc.exe' it compiles fine, with no problems. ( 'C Compiler' is 'mingw32-gcc.exe' or 'gcc.exe', changing it has no effect )

Normally i would not mind this, but as i use C and C++ i find it inconvenient to change the compiler each time.

Any help would be great,
Thanks,
    AndrewVinci

Just as a side, i have used -Werror, however CB uses -Wfatal-errors. Out of curiosity, why the difference?

Edit : forgot to add what flags i am compiling with. Under 'Other Options' in 'Compiler and debugger settings' i have '-std=c99 -Wall -Werror -pedantic' (without the ' ')

Elmar:
Hello AndrewVinci,
is the is the name of the C file realy file.c or is it file.C?
because only in lower case it would be comiled with mingw-gcc

elminator

johne53:
This might be related to a problem that I reported at the beginning of August - where source files with the extension "CC" were being compiled as 'C' files instead of 'C++'. That problem got fixed around August 8th or 9th. Maybe the fix introduced a related bug?

Biplab:

--- Quote from: johne53 on September 14, 2007, 05:56:37 pm ---This might be related to a problem that I reported at the beginning of August - where source files with the extension "CC" were being compiled as 'C' files instead of 'C++'. That problem got fixed around August 8th or 9th. Maybe the fix introduced a related bug?

--- End quote ---

I don't see where it reintroduced another bug??!!

I tried it with a c file.


--- Quote ----------------- Build: Debug in Console ---------------
[ 50.0%] mingw32-gcc.exe -Wall -fexceptions -g -std=c99  -IC:\MinGW\include  -c C:\Projects\Console\main.c -o obj\Debug\main.o
[100.0%] mingw32-g++.exe -LC:\MinGW\lib  -o bin\Debug\Console.exe obj\Debug\main.o   
Output size is 18.02 KB
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings
--- End quote ---

Then I renamed the file with a .cc extension. And as expected it generated a warning.

--- Quote ----------------- Build: Debug in Console ---------------
[ 50.0%] mingw32-g++.exe -Wall -fexceptions -g -std=c99  -IC:\MinGW\include  -c C:\Projects\Console\main.cc -o obj\Debug\main.o
cc1plus.exe: warning: command line option "-std=c99" is valid for C/ObjC but not for C++
[100.0%] mingw32-g++.exe -LC:\MinGW\lib  -o bin\Debug\Console.exe obj\Debug\main.o   
Output size is 19.02 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 1 warnings
--- End quote ---

johne53:
In your examples, C::B is selecting the correct compiler, depending on the source file extension. In AndrewVinci's original report, he was seeing different behaviour (wrong compiler being selected). That's very similar to the problem that I reported back in August. Since it got fixed, the fix works correctly - but only for new projects. Maybe AndrewVinci's project is an old one? I don't know - it's just a suggestion for him to explore.

Navigation

[0] Message Index

Go to full version