• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

#ActualKing Mir

Posted 11 February 2013 - 09:07 PM

Rather than using #define to define constants it's better to just make constants:

const size_t SIZE = 10;
This gives you type control and avoids macro expansion problems like the one you encountered.

Using #define is almost the same as using your a text editor's 'find-and-replace' function. There are some cases where it's useful, but usually it causes more problems than it solves.

Actually, I don't think this is true in C. I couldn't get this to work:
const int N = 10;

struct S {
int i[N];
};


#1King Mir

Posted 11 February 2013 - 08:57 PM

Rather than using #define to define constants it's better to just make constants:

const size_t SIZE = 10;
This gives you type control and avoids macro expansion problems like the one you encountered.

Using #define is almost the same as using your a text editor's 'find-and-replace' function. There are some cases where it's useful, but usually it causes more problems than it solves.

Actually, I don't think this is true in C. I couldn't get this to work:
const int N = 10;

struct S {
int i[N];
};