News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

C::B compiles in K&R C and not ANSI C...?

Started by LiK, May 19, 2009, 07:13:27 PM

Previous topic - Next topic

Jenna

Quote from: LiK on May 19, 2009, 11:35:44 PM
ok i enabled full-command-line logging but the message is exactly the same as above..

Please post the commandline !!!

rcoll

Did you see my example above, where it showed the compiler being called?  Yours has it also (somewhere).  That is the command I need to see.

For the version number ... open the command window, then CD to the directory with the gcc compiler.  Then issue the command "gcc -v".  I need to know what version of gcc you  are using.

Ringo

LiK

ok gcc version is 3.4.2 (mingw-special).

ok i see your line. its the build log. Here is mine
[ 50.0%] mingw32-g++.exe -pedantic -Wall -ansi -g    -c "C:\...\1.c" -o "C:\...\1.o"

it is using g++ instead of gcc.. why?
In compiler settings mingw32-gcc.exe is selected as default C compiler.
mingw32-g++.exe is selected for C++.

The file is blabla.c and when i create a new one i select C, not C++..


Thx

rcoll

The g++ compiler of course expects all input files to be be C++ files; I'm not sure how you got to this point.

Go to Settings->Compiler and Debugger and on the "Selected Compiler" list select the compiler you are using (probably called GNU GCC Compiler), then click the tab called "Toolchain executables".  There will be both a C compiler and a C++ compiler listed there.  Make sure that "mingw32-gcc.exe" is listed for the C compiler.

Ringo

LiK

Thing is that i did not change anything there..

yes i already checked there and its mingw32-gcc.exe as C compipler.

But for some reason it uses the mingw32-g++.exe compiler which is the selection for C++.

It will only work if i put mingw32-gcc.exe as C++ compiler(!)

Seems like it cannot see that my file is a C file (despite the fact that its .c)

MortenMacFly

Quote from: LiK on May 20, 2009, 07:54:01 PM
Seems like it cannot see that my file is a C file (despite the fact that its .c)
Look at the file's (!) properties what compiler environment is selected there. Maybe you changed that by accident.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

LiK

what do u mean? where do i find this?
file-> properties? (nothing strange there..)


Thank you

MortenMacFly

Quote from: LiK on May 21, 2009, 02:43:20 PM
what do u mean? where do i find this?
File -> properties -> tab "advanced" -> compiler variable and compiler. Do *not* modify just post what's written there.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

LiK

erm.... nothing?!!

check the image attached

[attachment deleted by admin]

MortenMacFly

Quote from: LiK on May 22, 2009, 12:22:01 AM
erm.... nothing?!!
...but you*did* create a project? Or do you try to compile a single file? If so - create a project. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

LiK

erm... no i didn't :shock:

i tried with project and the file compiles jsut fine! thank you!

But again.. why it did not compile as a single file? More specifically why it does compile but uses the wrong compiler?
Has to do with the project thing?

ie In ms visual C++ IDE u cannot (i think:P) compile a single file, *but* the compile etc buttons are non-clickable..

MortenMacFly

Quote from: LiK on May 22, 2009, 06:13:51 PM
why it does compile but uses the wrong compiler?
This is by design. Supporting single-file compilation has limitations (for several good reasons). Actually I would vote to disable it completely to avoid such misunderstandings.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

LiK

hm.. ok now i understand :)

btw.. better disable it completely or warn that it only compiles C++ single files!

Ceniza

Quote from: BloodyCakeActually I would vote to disable it completely to avoid such misunderstandings.

I would vote to improve it (that's what I use the most of C::B) :D

stahta01

Quote from: Ceniza on May 31, 2009, 03:46:23 PM
Quote from: BloodyCakeActually I would vote to disable it completely to avoid such misunderstandings.

I would vote to improve it (that's what I use the most of C::B) :D

I would vote to have an option to enable it; that by default is disabled.
Tim S
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]