C++ include guards do not seem to be working

后端 未结 2 1397
无人共我
无人共我 2020-12-17 06:19

I am getting error messages from the mbed C++ compiler that seem to be indicative of malfunctioning include guards.

In main.cpp, I include my header file as follows:

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-17 07:08

    You need to mark the declarations as "extern" like this:

    extern DigitalOut led1;
    

    Then define them (i.e. allocate storage for them) in sample.cpp by using the expression you used to have in the header.

提交回复
热议问题