Author Topic: #define error in CodeBlocks  (Read 7058 times)

Offline PsychadelicGumballMachine

  • Multiple posting newcomer
  • *
  • Posts: 15
#define error in CodeBlocks
« on: September 07, 2023, 07:44:27 pm »
I am running Code::Blocks version 20.03 on Windows 10 (22H2)
 The compiler I use is GNU GCC Compiler.

Anytime, whenever I use #define to define a constant, I am always greeted with the following error:
error: expected ';' , ',' or ')' before numeric constant.  I have never encountered this error before when using #define and don't know what it means.
what I wrote is: #define ARRAY_SIZE 5.
Any help anyone can offer would be greatly appreciated.

Thank you.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1603
Re: #define error in CodeBlocks
« Reply #1 on: September 07, 2023, 07:54:38 pm »
Why do you open a new thread with the same question?. Follow stahta01's advice in the original thread.

Offline PsychadelicGumballMachine

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: #define error in CodeBlocks
« Reply #2 on: September 08, 2023, 07:26:23 pm »
I did. It said to specify the build of codeblocks you're using, your OS details, etc. So I did that, to the best of my ability at least.  It also had stuff about how to bracket code so that it was easily distinguishable from other text, but that doesn't apply here. I figured it was best to open a new one rather than modify the original as people would be more likely to see it, dismiss it because it was missing info and not come back to it.
« Last Edit: September 08, 2023, 07:29:44 pm by PsychadelicGumballMachine »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7626
    • My Best Post
Re: #define error in CodeBlocks
« Reply #3 on: September 08, 2023, 08:05:38 pm »
Since you failed to post a full build log, I have decided you no longer want help from me.

Edit2: See also https://forums.codeblocks.org/index.php/topic,25519.msg173716.html#msg173716

Good Bye.

Tim S.
« Last Edit: September 08, 2023, 10:28:30 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 fredIcn

  • Single posting newcomer
  • *
  • Posts: 1
Re: #define error in CodeBlocks
« Reply #4 on: September 09, 2023, 02:59:44 pm »
Suggestion:
PsychadelicGumballMachine, start troubleshooting from the basics. Create and run a brand new test C project. After confirming that it compiles and run, in the 'helloWorld' code that was created automatically insert the #define and recompile. The issue should not occur, which makes the environment or particularly the affected project the prime suspect. The issue you report is not reproducible
To cover every angle, in case the basic 'helloWorld' code does have the issue when you add the #define, then please follow previous advise and provide the requested logs to the original thread. Opening a new thread with the same question is not right, a breach of  protocol; lesson learned we hope.

Offline PsychadelicGumballMachine

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: #define error in CodeBlocks
« Reply #5 on: September 09, 2023, 04:33:54 pm »
While I thank you for the actual answer, I will not be back here ever. This place, much like stack overflow, is one of the most unpleasant places I've ever been on the internet (which given the internet, is really saying something). It will never cease to amaze me that people on here are as unhelpful, rude, nasty and down right toxic as they are given that they are quickly being replaced by ChatGPT and the like (which I also use. ChatGPT didn't have an answer for this one). Imagine running a business and yelling at your customers to the point where they don't want to come back and then wondering why your business failed.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7626
    • My Best Post
Re: #define error in CodeBlocks
« Reply #6 on: September 09, 2023, 10:32:45 pm »
You can post a link to the FAQs but, you can't make the poster read and understand them.

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

Offline Krice

  • Almost regular
  • **
  • Posts: 150
Re: #define error in CodeBlocks
« Reply #7 on: September 11, 2023, 10:47:58 am »
That line is almost 100% not where the error happens, it's probably before it. You should post 10 lines of code before (and after) that line so we could take a look. Seems to be some kind of beginner problem, which isn't hard to make in C/C++.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7626
    • My Best Post
Re: #define error in CodeBlocks
« Reply #8 on: September 11, 2023, 05:53:07 pm »
That line is almost 100% not where the error happens, it's probably before it. You should post 10 lines of code before (and after) that line so we could take a look. Seems to be some kind of beginner problem, which isn't hard to make in C/C++.

Yep, the problem is most likely user error; but, that type of problem is off topic for this website.

https://forums.codeblocks.org/index.php/topic,9996.0.html

Quote
This is NOT a general programming board. "How do I write a program that....", "Can anybody teach me how to", "I have this homework", "My program doesn't run and I don't have the slightest idea of why because I'm a C++ newcomer", "What is a compiler", "What does gcc do" is the kind of questions that is FORBIDDEN to ask.
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