<p>I'm compiling a simple .c in visual c++ with Compile as C Code (/TC)
and i get this compiler error </p>

<blockquote>
  <p>error C2143: syntax error : missing ';' before 'type'</p>
</blockquote>

<p>on a line that calls for a simple struct </p>

<pre><code> struct foo test;
</code></pre>

<p>same goes for using the typedef of the struct.</p>

<blockquote>
  <p>error C2275: 'FOO' : illegal use of this type as an expression</p>
</blockquote>

[{'answer_id': 35336, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 1, 'selected': False, 'text': '<p>Did you accidentally omit a semicolon on a previous line? If the previous line is an <code>#include</code>, you might have to look elsewhere for the missing semicolon.</p>\n\n<p>Edit: If the rest of your code is valid C++, then there probably isn\'t enough information to determine what the problem is. Perhaps you could post your code to a <a href="http://pastebin.ca" rel="nofollow noreferrer">pastebin</a> so we can see the whole thing.</p>\n\n<p>Ideally, in the process of making it smaller to post, it will suddenly start working and you\'ll then have discovered the problem!</p>\n'}, {'answer_id': 35362, 'author': '17 of 26', 'author_id': 2284, 'author_profile': 'https://Stackoverflow.com/users/2284', 'pm_score': 0, 'selected': False, 'text': '<p>How is your structure type defined?  There are two ways to do it:</p>\n\n<pre><code>// This will define a typedef for S1, in both C and in C++\ntypedef struct {\n     int data;\n     int text;\n} S1;\n\n// This will define a typedef for S2 ONLY in C++, will create error in C.\nstruct S2 {\n     int data;\n     int text; \n};\n</code></pre>\n'}, {'answer_id': 35417, 'author': 'Will Dean', 'author_id': 987, 'author_profile': 'https://Stackoverflow.com/users/987', 'pm_score': 1, 'selected': False, 'text': "<p>Because you've already made a typedef for the struct  (because you used the 's1' version), you should write:</p>\n\n<pre><code>foo test;\n</code></pre>\n\n<p>rather than </p>\n\n<pre><code>struct foo test;\n</code></pre>\n\n<p>That will work in both C and C++</p>\n"}, {'answer_id': 35464, 'author': "Andrew O'Reilly", 'author_id': 3692, 'author_profile': 'https://Stackoverflow.com/users/3692', 'pm_score': 0, 'selected': False, 'text': "<p>C2143 basically says that the compiler got a token that it thinks is illegal in the current context. One of the implications of this error is that the actual problem may exist before the line that triggers the compiler error. As Greg said I think we need to see more of your code to diagnose this problem.</p>\n\n<p>I'm also not sure why you think the fact that this is valid C++ code is helpful when attempting to figure out why it doesn't compile as C? C++ is (largely) a superset of C so there's any number of reasons why valid C++ code might not be syntactically correct C code, not least that C++ treats structs as classes!</p>\n"}, {'answer_id': 35477, 'author': 'CiNN', 'author_id': 2566, 'author_profile': 'https://Stackoverflow.com/users/2566', 'pm_score': 4, 'selected': True, 'text': '<p>I forgot that in C you have to declare all your variables before any code.</p>\n'}]
['https://Stackoverflow.com/questions/35333', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2566/']