开发者

how visual studio tell c++ and c?

As the title says,does the visual studio distinguish these two files by their suffix?.c or .cpp? I also have another question.At first,I stated the program like this:

int main(int argc, char **argv)
{
  LARGE_INTEGER TimeStart;
  LARGE_INTEGER TimeEnd;
  QueryPerformanceCounter(&TimeStart);
  static double Freq;
  static int getfreq; 
  double mu,om;
  double *v;
  int it,i,j;
 ....
}

but it brings out many problems:

1>sor2d.c(23): error C2143: syntax error : missing ';' before 'type'
1>sor2d.c(24): error C2143: syntax error : missing ';' before 'type'
1>sor2d.c(25): error C2143: syntax error : missing ';' before 'type'
1>sor2d.c开发者_如何学JAVA(26): error C2143: syntax error : missing ';' before 'type'

23 ling points to "static double Freq;" but if I put "QueryPerformanceCounter(&TimeStart);" after the data allocation,the compiler can succeed.Could someone tell me why this happened,was is just because of my carelessness of omitting something or ignorance...?


In C, all variables must be declared before calling any methods.

Visual Studio will, by default, compile .C files as C. You can override this.


In C89, you must declare all of your variables at the top of the code block. You may also initialize them to compile-time constants (literals, macros that expand to literals, the values of variables that have already been initialized, and any operations on the above that can be performed at compile time). You cannot intersperse other types of statements (like function calls) within these declarations.

This limitation was removed in C99 (which is not supported by Visual C++) and C++.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜