Author Topic: Configuring Code::Blocks to follow older standards of C.  (Read 4517 times)

Offline 93NickCousar

  • Single posting newcomer
  • *
  • Posts: 6
Configuring Code::Blocks to follow older standards of C.
« on: September 16, 2018, 10:33:35 pm »
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
« Last Edit: September 17, 2018, 07:58:39 am by 93NickCousar »

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: Configuring Code::Blocks to follow older standards of C.
« Reply #1 on: September 17, 2018, 12:41:37 am »
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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Configuring Code::Blocks to follow older standards of C.
« Reply #2 on: September 17, 2018, 04:18:13 am »
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.
« Last Edit: September 17, 2018, 05:58:56 pm by stahta01 »
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

Offline 93NickCousar

  • Single posting newcomer
  • *
  • Posts: 6
Re: Configuring Code::Blocks to follow older standards of C.
« Reply #3 on: September 17, 2018, 08:11:02 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.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Configuring Code::Blocks to follow older standards of C.
« Reply #4 on: September 17, 2018, 09:25:55 am »
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).

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: Configuring Code::Blocks to follow older standards of C.
« Reply #5 on: September 18, 2018, 03:03:57 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).

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.