# How would you fix this?

This topic is 1851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))

#define list_for_each_entry_safe(pos, n, head, member)   \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head);      \
pos = n, n = list_entry(n->member.next, typeof(*n), member))

list_for_each_entry_safe(ent, iter, &(tq->q), q_node) {
list_del(&ent->q_node);
free(ent);
}



The errors:

1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1226): error C2059: syntax error : ')'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1229): error C2059: syntax error : ')'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1231): warning C4552: '!=' : operator has no effect; expected operator with side-effect
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1232): error C2059: syntax error : ')'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2059: syntax error : 'for'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2059: syntax error : '&'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2065: 'iter' : undeclared identifier
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2099: initializer is not a constant
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2100: illegal indirection
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2059: syntax error : ')'


I did not write the code,I'm just trying to make it compile.

##### Share on other sites
Check that there's no whitespace after the \'s. If there is, that might be screwing VS up. It seems to have copy pasted without it, but maybe to original has it. Edited by King Mir

##### Share on other sites

You could try putting the macros all on one line to rule out odd whitespace or indentation issues.

-Josh

##### Share on other sites

...that did not work either

##### Share on other sites
Maybe the problem is on a line above the posted code.

##### Share on other sites

above the posted code there are just comments

##### Share on other sites
What lines are those errors actually in? The error may be caused by the context in which you're expanding them.

##### Share on other sites
The best solution is to compile it with gcc like it was meant to be.

The Microsoft and gcc preprocessors do not work identically. This code fragment (the macro definitions themselves actually come from the linux kernel) was written to compile with gcc, and so in the Microsoft compiler the macros do not get expanded as intended. It will likely take much more work to rewrite them to expand properly with the Microsoft compiler than to use to right compiler to begin with.

##### Share on other sites

Because this is a compilation error of the precompiled source, the precompiled source is already available. Just dump the precompiled source to a file, and look at the line where the bug happens. Possibly you can find out what was the bug with this.

In the C or C++ file's Property sheet select C/C++ in the tree and then select Preprocessor. There is a switch 'Preprocess to a File'. When you switch it on, it will generate a preprocessed output, instead of compiling the file at the next build. The file will be named after your source file with a .i extension and is put in the intermediate directory where the object files are. (I think it's possible to put elsewhere with a different name, but not in the Express version.)

##### Share on other sites

I believe the problem comes from using "typeof", which is a C extension of GCC.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634047
• Total Posts
3015231
×