Author Topic: C compiling as C++  (Read 8745 times)

Offline AndrewVinci

  • Single posting newcomer
  • *
  • Posts: 3
C compiling as C++
« on: August 25, 2007, 03:00:27 pm »
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 ' ')
« Last Edit: August 25, 2007, 03:03:54 pm by AndrewVinci »

Offline Elmar

  • Single posting newcomer
  • *
  • Posts: 3
Re: C compiling as C++
« Reply #1 on: September 13, 2007, 10:16:27 pm »
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

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: C compiling as C++
« Reply #2 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?

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: C compiling as C++
« Reply #3 on: September 14, 2007, 07:21:47 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?

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

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
Be a part of the solution, not a part of the problem.

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: C compiling as C++
« Reply #4 on: September 14, 2007, 08:03:43 pm »
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.