Sign in to follow this  
noatom

How would you fix this?

Recommended Posts

noatom    927
#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 this post


Link to post
Share on other sites
King Mir    2490
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 this post


Link to post
Share on other sites
jjd    2140

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

 

-Josh

Share this post


Link to post
Share on other sites
Anthony Serrano    3285
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 this post


Link to post
Share on other sites
zaphod2    1522

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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this