News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Configuring Code::Blocks to follow older standards of C.

Started by 93NickCousar, September 16, 2018, 10:33:35 PM

Previous topic - Next topic

93NickCousar

I'm trying to do some of the practice exercises in Kernighan & Ritchies The C Programming Language (2nd Edition), which was published in 1988. Most of the practice problems do not output as intended. I'm not sure why, but I think it may have to do with the C standards that the GCC compiler follows. This book was almost certainly written before the C99 standard was implemented so I think that is what is causing some of the programs to not run properly. Anyways, I was wondering if there was some setting in Code::Blocks I could change that would allow for programs written with an older standard of C to still be compiled correctly. This dialog box in the Project>Build Options tab looks promising, but I don't know which box to check. Would changing any of these settings work?

online pic hosting

sodev

Throw away that book and get a recent one. Unless you work in a museum and prepare an exhibition. You can try the lowest language revision CodeBlocks offers (the numbers are years, 90 == 1990, 11 == 2011), but im not sure if any non-ancient gcc implements that old standard of that book anymore.

But depending what not outputting as intended is i doubt the standard has do much of an influence, it does have an influence to get the programs to compile and not crash instantly.

stahta01

#2
Try "-std=c89" or "-std=c90" they are likely the oldest supported by most recent GCC compilers.

For better answer ask on a site that supports the compiler you are using.

Edit2: Offsite link added https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Standards.html#Standards

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]

93NickCousar

Quote from: sodev on September 17, 2018, 12:41:37 AM
Throw away that book and get a recent one.

Can you recommend a book for a first year CS student? Perhaps something that goes into the theory/rationale behind certain programming concepts, and how they are implemented in C? I could also use a good reference book for specific rules and syntax.

BlueHazzard

Without telling us what errors you have we can not help you much, but it is very unlikely that your runtime problems come from different c standards. Maybe your book is accessing raw memory? If there are differences then it is a operating system thing. C standards make the most difference on compile time. On runtime all should behave the same (minus some weird bugs).

sodev

Quote from: 93NickCousar on September 17, 2018, 08:11:02 AM
Can you recommend a book for a first year CS student?
I am not a reading guy, i am more a doing guy. I never read any "how do i start programming in x" book and first year CS is far behind me, so i can't recommend anything up-to-date here. The last books i bought and partly read have been Effective C++ and Effective Modern C++, but i think these are not your topic right now (plus they are not about C but C++ only).

Quote from: 93NickCousar on September 17, 2018, 08:11:02 AM
I could also use a good reference book for specific rules and syntax.
Now here i can deliver, my most favorite one is https://www.cppreference.com, despite the name it also covers C. Another one is http://www.cplusplus.com but its not so good like the first one IMHO.