0

I get realy confused by one problem to bring a mapping for an arduino project in a module .h file. I previously bouild all up in one file. There the compilation was without any problems and the ode runs perfectly. Now I get an error after I put it in a module .h file:

expected constructor, destructor, or type conversion before '<' token

for that part of my code:

std::map < std::string, btComands > mapStringBtComands;

I'm not able to find out where the problem is.

Here is the complete .h:

// bluetooth.h

#ifndef _BLUETOOTH_h
#define _BLUETOOTH_h

#if defined(ARDUINO) && ARDUINO >= 100
    #include "Arduino.h"
#else
    #include "WProgram.h"
#endif

#include <StandardCplusplus.h>
#include <map>
#include <string>

#ifdef BT_ENABLED

enum btComands
{
    setPID  =   1, // set PID parameters
    getPID  =   2, // send PID vlaues to bluetooth
    stEEP   =   3, // store parameters to EEPROM
    setLD   =   4, // activate Live date streaming to Bluetooth
    setLog  =   5,  //activate Log streaming over Bluetooth
    setMaxSpeed = 6 // define max allowed Speed

};


//initalisation of mapping for bluetooth GetCommand

std::map < std::string, btComands > mapStringBtComands;

void inline InitBtCommands()
{

    mapStringBtComands["setPID"]=setPID;
    mapStringBtComands["getPID"]=getPID;
    mapStringBtComands["stEEP"]=stEEP;
    mapStringBtComands["setLD"]=setLD;
    mapStringBtComands["setLog"]=setLog;
    mapStringBtComands["setMaxSpeed"]=setMaxSpeed;
}



#endif
#endif

I hope somebody can help me.

Regards

Andreas

Greccofly
  • 1
  • 1
  • It's really hard to say anything without knowing *what* error you have. Please edit your question to include the complete and unedited error log. – Some programmer dude May 05 '15 at 08:29
  • However, I would guess that you have multiple definition linker errors, because you *defined* the variable `mapStringBtComands` in the header file, instead of just declaring it. That means the variable will be defined in all source files that includes your header file. Instead only *declare* it, and define it in a single source file. You can declare it by prepending the line with the `extern` keyword. – Some programmer dude May 05 '15 at 08:30
  • 2
    Does Arduino even have `std::map` and `std::string`? – Wintermute May 05 '15 at 08:31
  • On an unrelated note, symbols with a leading underscore and a capital letter are reserved, don't use them. See e.g. [this old answer](http://stackoverflow.com/a/228797/440558). – Some programmer dude May 05 '15 at 08:32

0 Answers0