sách gpt4 ăn đã đi

c++ - #ifndef không hoạt động như mong đợi

In lại 作者:太空狗 更新时间:2023-10-29 23:37:18 26 4
mua khóa gpt4 giày nike

为 PAL.h 中的函数指针获取“已在 GUI.obj 中定义”的 LNK2005

//GUI.cpp
#include "PAL.h"

//PAL.h
#define PAL_INCLUDE
int (*addPAL)( int, void(*)(), void(*)() );

//main.cpp
#include "GUI.h"
#ifndef PAL_INCLUDE
#include "PAL.h"
#kết thúc nếu

我是否误解了 include 和 #ifndef 的本质?

câu trả lời hay nhất

您收到错误可能是因为预处理器在 GUI.cpp 之前处理 main.cpp。尝试将 PAL.h 的内容更改为:

 #ifndef PAL_INCLUDED
#define PAL_INCLUDED
// definitions
#kết thúc nếu

引用

Include guard

关于c++ - #ifndef 没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8334416/

26 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress