I've been racking my head trying to start programming in a library organized method. My code works, but the translation and split to a .h and .cpp file is riddled with errors.
It's gotta be stupidly simple all I'm asking for is a review:
Header File
# ifndef _INITIALIZE_H
#define _INITIALIZE_H
#if (ARDUINO >= 100)
# include <Arduino.h>
#else
# include <WProgram.h>
#endif
//-Extra Includes-
#include <config.h> //Provides baud...
#include <SSC32.h>
#define STANDARD 0
#define DEBUG 1
#define VIRTUAL 2
class Initialize {
private:
int _mode;
public:
Initialize();
void begin();
};
#endif
associated .cpp file:
//Comments
#include <Initialize.h>
SSC32 SSC;
Initialize::Initialize()
{
_mode = STANDARD;
}
void Initialize::begin()
{
SSC.begin(baud);
if(Serial.available() > 0){
if(sscReturn == 1){
Serial.println("ver");
}
}
}
The error from the compiler:
D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp: In member function 'void Initialize::begin()':
D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:9:12: error: expected primary-expression before '=' token
D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:9:16: error: expected primary-expression before ')' token
D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:9:16: error: expected ';' before ')' token
D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:11:7: error: expected primary-expression before '=' token
D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:11:7: error: expected ')' before ';' token
D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:11:17: error: expected primary-expression before '==' token
D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:11:21: error: expected ';' before ')' token
Failed compiling libraries
-
1What is sscReturn?Majenko– Majenko2015年07月15日 01:15:08 +00:00Commented Jul 15, 2015 at 1:15
-
Where is sscReturn declared? This seems to be the (main) cause of the compiler errors.Greenonline– Greenonline2015年09月21日 23:45:50 +00:00Commented Sep 21, 2015 at 23:45
1 Answer 1
Sorry, figured it out.
In the "config.h" file I was pulling, I had a
#define = 18;
instead of a #define 18
I might be wrong, but the compiler stopped complaining
-
4What are you defining as 18?Majenko– Majenko2015年07月15日 08:23:22 +00:00Commented Jul 15, 2015 at 8:23
-
3@user you cannot just type #define 18, it should be something like #define xyz 18. This means that from now on in your code xyz will be replaced by 18 (arduino.cc/en/Reference/Define)evolutionizer– evolutionizer2015年08月14日 05:14:17 +00:00Commented Aug 14, 2015 at 5:14
-
2
I might be wrong
- You are wrong. The line#define 18
doesn't compile:error: macro names must be identifiers
. This is not a helpful answer. I'm going to vote to close the question and the answer.2015年09月13日 05:42:09 +00:00Commented Sep 13, 2015 at 5:42