Resolving a linker error: undefined reference to static class members

后端 未结 4 1260
甜味超标
甜味超标 2020-12-21 03:31

My code is Arduinoish. I turned on verbose compiling so I could verify that all the .o files are indeed getting passed to the linker correctly, and they are (linker command

4条回答
  •  别那么骄傲
    2020-12-21 04:02

    You have to define your class statics in a source file some where. Putting them in the class just declares that they are there, but something still needs to define them.

    Inside your .cpp file your can do so like this:

    NewSoftSerial SerialServoControl::_serial(9, 8);
    char SerialServoControl::_tx = 0;
    char SerialServoControl::_rx = 0;
    

    Put appropriate initial values; I just assumed the comment was for the constructor.

提交回复
热议问题