Jump to content

  • Log In with Google      Sign In   
  • Create Account


How would you fix this?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 20 December 2013 - 01:06 PM

#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.



Sponsor:

#2 King Mir   Members   -  Reputation: 1936

Like
0Likes
Like

Posted 20 December 2013 - 01:31 PM

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, 20 December 2013 - 01:31 PM.


#3 jjd   GDNet+   -  Reputation: 2075

Like
0Likes
Like

Posted 20 December 2013 - 01:36 PM

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

 

-Josh


--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet


#4 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 20 December 2013 - 01:56 PM

...that did not work either



#5 King Mir   Members   -  Reputation: 1936

Like
0Likes
Like

Posted 20 December 2013 - 01:59 PM

Maybe the problem is on a line above the posted code.

#6 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 20 December 2013 - 02:19 PM

above the posted code there are just comments



#7 SeanMiddleditch   Members   -  Reputation: 4831

Like
0Likes
Like

Posted 20 December 2013 - 03:24 PM

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

#8 Anthony Serrano   Members   -  Reputation: 1143

Like
0Likes
Like

Posted 20 December 2013 - 04:54 PM

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.

#9 zaphod2   Members   -  Reputation: 612

Like
1Likes
Like

Posted 21 December 2013 - 08:05 AM

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.)



#10 Pink Horror   Members   -  Reputation: 1117

Like
2Likes
Like

Posted 21 December 2013 - 07:48 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS