d:\program files\microsoft visual studio\vc98\include\xstring(133) : error C2059: syntax error : 'end of file'当我把另一个工程的文件拷贝的这个工程中,解决了所有头文件的错误之后.
出现的.(有Dialog)

解决方案 »

  1.   

    在这个cpp文件的头上包含 stdafx.h 试试
      

  2.   

    是语法错误,例如:
    void main (   // 这里有问题
    {}在双击出错信息提示,在源代码的上一行,或者上几行查找是否有语法错误。
      

  3.   

    该标记导致语法错误。若要确定原因,则不仅要检查在错误信息中列出的行,还要检查该行上面的行。以下示例对包含左大括号的行生成了错误信息,而该错误的真正原因却出现在其上面的行中。// C2059a.cpp
    int main )   // C2059 No opening parenthesis.
    {
    }
    如果对行的检查没有获得有关可能出现的问题的任何线索,则尝试注释掉在错误信息中列出的行以及可能出现在该行上面的若干行。如果该错误信息在紧跟 typedef 变量的符号上出现,则检查该变量是否已在源代码中定义。如果符号没有计算出任何结果(在使用 /Dsymbol= 编译时可能发生),则可能会获得 C2059。// C2059b.cpp
    // compile with: /DTEST=
    #include <stdio.h>
    int main()
    {
       #ifdef TEST
          printf("\nTEST defined %d", TEST);   // C2059
       #else
          printf("\nTEST not defined");
       #endif
    }可能收到 C2059 的另一个特定原因是编译在函数的默认参数中指定了结构的应用程序。参数的默认值必须是一个表达式。初始值设定项列表(如用于初始化结构的初始值设定项列表)不是表达式。下面的示例生成 C2059:// C2059c.cpp
    struct ag_type 
    {
       int a;
       float b;
    };void func(ag_type arg = {5, 7.0});   // C2059
    其解决方法是定义一个执行所需初始化的构造函数。struct ag_type { 
       int a; 
       float b; 
       ag_type(int aa, float bb) : a(aa), b(bb) {} 
    }; 
    void func(ag_type arg = ag_type(5, 7.0)); 
    int main()
    {
    }
    如果您在类外定义成员模板类或函数,也可能获得 C2059。
      

  4.   

    stdafx.h 通常应该第一个包含,请检查你的头文件包含的顺序。如果顺序没问题,请检查你的宏定义。
      

  5.   

    我遇到过几次这样的问题,提示文件未完什么的。双击出错信息提示,它把我带到这个文件的最后一行,怎么检查也没有错。最后发现原因就是没有加入stdafx.h,所有使用了预编译头的工程中,每个文件都必须加入stdafx.h。
      

  6.   

    我是从另外一个工程中拷进来的文件,在原来的工程中是可以运行的.
    所以原来的.cpp中必定包含了 stdafx.h .而且我刚才也检查过了!错误出现行是在mfc中的文件中:
    _Myt& assign(const _E *_S, size_type _N)
    {if (_Grow(_N, true))
    {_Tr::copy(_Ptr, _S, _N);
      

  7.   

    而我之后改的也是如 resource.h 和一些头文件的路径,
    还有一个就是
    把原来对话框中的CAboutDlg给删除了,因为是在同一个文件中.
    之后也把OnSysCommand事件改成这样:
    /*
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal();
    }
    else
    {
    */
    CDialog::OnSysCommand(nID, lParam);
      

  8.   

    不知道为什么,其它文件都没事,就只有Dialog的那个有问题.
      

  9.   

    syntax error : 'token'The token caused a syntax error.To determine the cause, examine not only the line listed in the error message, but also the lines above it. The following example generates an error message for the line containing the open curly brace, but the true source of the error appears on the line just above it. // C2059a.cpp
    int main )   // C2059 No opening parenthesis.
    {
    }
    If examining the lines yields no clue to what the problem might be, try commenting out the line listed in the error message and possibly several lines above it.If the error message occurs on a symbol immediately following a typedef variable, check that the variable is defined in the source code.You may get C2059 if a symbol evaluates to nothing, as can occur when you compile with /Dsymbol=.// C2059b.cpp
    // compile with: /DTEST=
    #include <stdio.h>
    int main()
    {
       #ifdef TEST
          printf("\nTEST defined %d", TEST);   // C2059
       #else
          printf("\nTEST not defined");
       #endif
    }Another specific reason you can get C2059 is when you compile an application that specifies a structure in the default arguments for a function. The default value for an argument must be an expression. An initializer list, such as that used to initialize a structure, is not an expression. The following example generates C2059:// C2059c.cpp
    struct ag_type 
    {
       int a;
       float b;
    };void func(ag_type arg = {5, 7.0});   // C2059
    The resolution is to define a constructor to perform the required initialization. struct ag_type { 
       int a; 
       float b; 
       ag_type(int aa, float bb) : a(aa), b(bb) {} 
    }; 
    void func(ag_type arg = ag_type(5, 7.0)); 
    int main()
    {
    }
    You can also get C2059 if you define a member template class or function outside the class. See Knowledge Base article Q241949 for more information.
      

  10.   

    问题找到了!,谢谢 。
    果然是那个cpp文件啊,
    namespace XXX
    { 名字空间中没有加括号。还本这里有一个CAboutDlg,
    有个namespace XXX,后来删除的时候没有删干尽。(
    我在原本的工程中所有的类
    都加上了名字空间。
    )
      

  11.   

    这个错误一下子就跳到MFC中,把我给搞糊涂了,呵呵。