Error: namespace cannot compile

28 Sep 2012

Please help, Going a bit crazy thismorning,

I want to split out sone code for a sensor (qiute sensible I thought) but i keep getting an error,

Even with NO code in the seperate files,

What am I doing wrong,

BTW: sompthing very simmilar on a much older project works :(

main.c

#include "mbed.h"
#include "DPot.h"

DigitalOut myled(LED1);

int main() {

Dpot_init();

    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

dpot.c

#include "mbed.h"
#include "CapSens.h"


// I2C DPot_Port (p28,p27);

void DPot_init(void)
{
    //

}

dpot.h

#ifndef _DPot_h_
#define _DPot_h_


void DPot_init(void);

#endif  // _DPot_h_
28 Sep 2012

I'm crazy too, that below do not compile.

/media/uploads/hmariod/screen_shot_2012-09-28_at_8.15.25_am.png

01 Oct 2012

I Have just attempted this, and I gte the same ERROR ??

Do not understand it either,

What is wrong ??

Cheers Lex.

01 Oct 2012

Hi Ceri, Lex,

Looks like it might be that you are trying to use C++ code in a C file (e.g. including mbed.h in dpot.c, which is C++).

Perhaps your .c files should be .cpp?

One great way to make it easy for people to answer these sorts of questions is to publish an example program demonstrating the problem. It is then it is a single-click import to reproduce the problem for anyone who might be willing to have a go (else you are left trying to guess and reconstruct the problem!). And they can even publish the answer as a fix changeset on the repository, so you can see exactly what they changed!

Hope that helps!

Simon

01 Oct 2012

Lexingtong, You must include the RTOS library.

http://mbed.org/users/mbed_official/code/mbed-rtos/

Cheers!