开发者

Errors on whitespace?

开发者 https://www.devze.com 2023-03-14 07:18 出处:网络
So I am trying to compile a set of C files written by someone else, and I am continually getting the following error:

So I am trying to compile a set of C files written by someone else, and I am continually getting the following error:

TBin.h:10: error: expected '=', ',', ';', 'asm'开发者_开发问答 or 'attribute' before 'TBin'

This is occurring in a .h file, which currently has a #ifndef and #define before the class definition. The line itself is:

class TBin {

There is nothing else before that in the file, no includes, no comments, no random bits of anything. Even if I remove the guards and move the declaration right up to the top of the file, I get the same error. I thought this could only occur if there was an issue in the preceding code, but I have no preceding code! Ideas?


You can't use "class" in C. Try a C++ compiler. ;-)

Just for comparison, here's the output from clang:

% ~/ellcc/bin/ecc ~/test.c 
/home/rich/test.c:1:1: error: unknown type name 'class'
class TBin {
^
/home/rich/test.c:1:11: error: expected ';' after top level declarator                                        
class TBin {
          ^
          ;                                                                                                  
2 errors generated.

A little more descriptive, maybe, but not too much.


It looks like definition of TBin is missing in your header file. Try to figure out where TBin datatype (or typdef or something) is defined in yor source tree and try to include that header file in yourproblem header file. To provide whole line caused error would be very helpful.


You're trying to compile C++ code with a C compiler. Are you by any chance using gcc? If you compile C++ code, you need g++ instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消