b28*_*ff1 1 c++ compilation token
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <limits>
#include <stdexcept>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "definitions.h"
#include "globals.h"
};using namespace std;
Run Code Online (Sandbox Code Playgroud)
这是functions.h现在我们有main.cpp包括标题
#include "functions.h"
int main(int argc, char *argv[])
{
//Other stuff
return 0;
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我必须};在using声明之前写.它不会让我编译,除非它在它之前.
任何想法为什么?
这个错误可能是由丢失引起};的在globals.h文件中.
预处理器将#included头文件的内容直接粘贴到源文件中.因此,如果其中一个头文件中存在语法错误,则源文件中将包含语法错误.
我知道这不能解决你的问题,但你永远不应该using namespace std;在头文件中使用,因为它会污染包含该头的每个翻译单元的全局命名空间.将using namespace语句本地保存到单个源文件要好得多,或者更好,只需输入std::.