Multiple Defines on One Line
Can that be done? This is just to make my code neater because I do 16 defines and my code is spagetti elsewhere.
Sir, e^iπ + 1 = 0, hence God exists; reply!
I'm pretty sure that this is not possible. You can go the other way, however (one define spanning multiple lines)...
Put them in a separate header file if you don't want it cluttering your other files.
Put them in a separate header file if you don't want it cluttering your other files.
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
That wouldn't really make your code any neater, anyways.
I assume this is c/c++, in which case if you're relatively new with the language it's also a good idea for constants not do #define them, but to use a const variable instead. That way you get type-checking for free.
It however, would have some interesting applications in the IOCCC... 
But yeah, Josh is right - whitespace is good! If your code is spaghetti to the point where you dread reading it, it may be better to reformat it now (possibly even recode some parts) before you get too far away from it. If you can't read it, you generally can't debug it.

But yeah, Josh is right - whitespace is good! If your code is spaghetti to the point where you dread reading it, it may be better to reformat it now (possibly even recode some parts) before you get too far away from it. If you can't read it, you generally can't debug it.
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
what is IOCCC, my codes spagetti because I thought it would be funny to program the entire game mechancs in one procedure, I think of wierd things when I dont sleep! But its kind of cool looking that way, its crazy and I like it.
phydeaux: Its ObjectiveC, Im not relatively new to C but im always learning
(ive just never read a book on it). Type checking is not necassary here because all im defining is integers describing the position of graphics in a file.
I think ill move the def's to a seperate file.
thanks a lot
phydeaux: Its ObjectiveC, Im not relatively new to C but im always learning
(ive just never read a book on it). Type checking is not necassary here because all im defining is integers describing the position of graphics in a file.I think ill move the def's to a seperate file.
thanks a lot
Sir, e^iπ + 1 = 0, hence God exists; reply!
GIYF: http://www.google.com/search?q=IOCCC
It's going to be funny up to the point where you want to change something. Trust me, I've been there. It will be painful later.
If you wish to learn that on your own, I will not stop you
It's going to be funny up to the point where you want to change something. Trust me, I've been there. It will be painful later.
If you wish to learn that on your own, I will not stop you
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
hahaha, ive heard about that before its pretty cool, Check the obfuscated Quines (self replicators) though!!! I dont know if my codes up to that standard yet! Yeah ive started breaking it up slightly and making it more legible.
Sir, e^iπ + 1 = 0, hence God exists; reply!
phydeaux: the "constant variable" approach doesn't work well for C, due to differences in the meaning of "const" between C and C++.
If you put "const int FOO = 3;" in a header file in C, you'll get "multiply defined" link errors for every source file that includes the header. In C++, that'll work correctly.
In order to make it work at all in C, you need to put "static const in FOO = 3;", which will cause a copy of the variable to be emitted for each source file that includes the header, but will avoid the link errors. I'm not sure if it's true any more, but it used to cause GCC to treat it as if it were a global variable rather than an integer constant (much, much slower). If I had to guess, I'd suspect it will be true until GCC 4.1.
In order to make it work at all in C, you need to put "static const in FOO = 3;", which will cause a copy of the variable to be emitted for each source file that includes the header, but will avoid the link errors. I'm not sure if it's true any more, but it used to cause GCC to treat it as if it were a global variable rather than an integer constant (much, much slower). If I had to guess, I'd suspect it will be true until GCC 4.1.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Read a text file line by line? | jdunehew | 6 | 9,210 |
Dec 29, 2011 11:54 AM Last Post: Blacktiger |
|

