Author Topic: C::B compiles in K&R C and not ANSI C...?  (Read 18777 times)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #15 on: May 20, 2009, 12:05:32 am »
ok i enabled full-command-line logging but the message is exactly the same as above..

Please post the commandline !!!

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #16 on: May 20, 2009, 12:07:42 am »
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

Offline LiK

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #17 on: May 20, 2009, 09:51:21 am »
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

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #18 on: May 20, 2009, 06:50:04 pm »
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

Offline LiK

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #19 on: May 20, 2009, 07:54:01 pm »
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)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #20 on: May 21, 2009, 02:13:10 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline LiK

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #21 on: May 21, 2009, 02:43:20 pm »
what do u mean? where do i find this?
file-> properties? (nothing strange there..)


Thank you

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #22 on: May 21, 2009, 07:03:53 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline LiK

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #23 on: May 22, 2009, 12:22:01 am »
erm.... nothing?!!

check the image attached

[attachment deleted by admin]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #24 on: May 22, 2009, 06:47:06 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline LiK

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #25 on: May 22, 2009, 06:13:51 pm »
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..

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #26 on: May 25, 2009, 07:15:49 am »
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline LiK

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #27 on: May 25, 2009, 12:09:36 pm »
hm.. ok now i understand :)

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

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #28 on: May 31, 2009, 03:46:23 pm »
Quote from: BloodyCake
Actually 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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: C::B compiles in K&R C and not ANSI C...?
« Reply #29 on: June 01, 2009, 01:16:05 am »
Quote from: BloodyCake
Actually 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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org