#21016 - mr_schmoe - Fri May 21, 2004 6:04 pm
Here's what my compiler says:
Code: |
request for member `init' in `2', which is of non-aggregate type `int' |
here the code:
function prototype:
Code: |
int cSprite::init(u16 numcolors, u16 size, u16 shape, u16 palettenum, u16 priority) |
function call:
Code: |
ok = weapon.init(COLOR_16, SIZE_16, SQUARE, 0, 1); |
does anyone know what I suppose to fix or do you need more infomation?
#21018 - mr_schmoe - Fri May 21, 2004 6:26 pm
never mind, I figured it out. Turns out I had a #define using the same identifier 'weapon'. Thanks anyways.
#21019 - sajiimori - Fri May 21, 2004 6:27 pm
My first guess would be that you're #defining 'weapon' to be the number 2, but otherwise the code looks fine.
edit: well, alright then.
#21023 - tepples - Fri May 21, 2004 7:30 pm
Moral: Give your macros all-capital names so that they don't collide with symbols such as variables.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#21095 - mr_schmoe - Sun May 23, 2004 8:54 pm
Quote: |
Moral: Give your macros all-capital names so that they don't collide with symbols such as variables. |
That is a good moral, I'll put it into practice right away. Thanks
#21106 - poslundc - Sun May 23, 2004 10:55 pm
*nitpick* using capitals for constants is widely adopted, but it's not a standard or anything.
Although it's a good way to go for others reading your code... and I can't really suggest any compelling reason not to do it that way.
But I've seen other systems in practice. In particular I've used a lowercase-k prefix with people who are fond of Hungarian notation, eg.:
#define kPi 3.1942654
#define kGravity 9.81
So it's all up to you.
Dan.
#21553 - Quirky - Mon May 31, 2004 9:29 pm
#defines are a traditionally C way of doing things, the C++ way is to use static consts instead of defines, where reasonable.