typedef, define and array

Apr 13, 2009 at 1:01pm
when I'm using something like
1
2
3
#define DIR_TOTAL        4;
...
typedef int T15Array[DIR_TOTAL][DIR_TOTAL];

istead of
typedef int T15Array[4][4];
I have pointless error messages. How should I do it properly?
Apr 13, 2009 at 1:22pm
I don't see any reason why that wouldn't work. What error message(s) are you getting?

Also -- don't use #define. use a const int instead:

 
const int DIR_TOTAL = 4;
Apr 13, 2009 at 1:42pm
1>c:\my documents\visual studio 2008\projects\fifteen\fifteen\fifteen.h(26) : error C2143: syntax error : missing ')' before ';'
1>c:\my documents\visual studio 2008\projects\fifteen\fifteen\fifteen.h(26) : error C2143: syntax error : missing ']' before ')'
1>c:\my documents\visual studio 2008\projects\fifteen\fifteen\fifteen.h(26) : error C2143: syntax error : missing ';' before ')'
1>c:\my documents\visual studio 2008\projects\fifteen\fifteen\fifteen.h(26) : error C2059: syntax error : ')'
1>c:\my documents\visual studio 2008\projects\fifteen\fifteen\fifteen.h(26) : error C2059: syntax error : ']'
1>c:\my documents\visual studio 2008\projects\fifteen\fifteen\fifteen.h(26) : error C2143: syntax error : missing ')' before ';'
1>c:\my documents\visual studio 2008\projects\fifteen\fifteen\fifteen.h(26) : error C2059: syntax error : ']'

errors with typedef int T15Array[DIR_TOTAL][DIR_TOTAL];

thanks for reply, everything fine with const instead #define
Last edited on Apr 13, 2009 at 1:45pm
Apr 13, 2009 at 1:56pm
Line 1 should be without ;
Apr 13, 2009 at 2:22pm
thanks, with #define DIR_TOTAL 4 also works :)
Topic archived. No new replies allowed.