On Tue, Jan 25, 2011 at 12:58 PM, Marcel Holtmann <marcel(a)holtmann.org> wrote:
Hi Lucas,
> >> - const char *old, const char *new,
> >> + const char *p_old, const char *p_new,
> >> ofono_sim_lock_unlock_cb_t cb, void *data);
> >> void (*lock)(struct ofono_sim *sim, enum ofono_sim_password_type
type,
> >> int enable, const char *passwd,
> >
> > why is this exactly a problem?
>
> I did it only because the file contains this:
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
>
> So I thought someone might want to write a plugin in C++ or something
> that includes sim.h
and at that point you told the compiler that it is C code and not C++
and it should be just fine.
This only works for the link phase, because of the name mangling in C++.
I think it will compile just fine. Try to test it ;)
It doesn't. Example:
c.h
---
#ifdef __cplusplus
extern "C" {
#endif
int func(int *old, int *new);
#ifdef __cplusplus
}
#endif
---
cpp.cpp
---
#include <iostream>
#include "c.h"
using namespace std;
int main(int argc, char *argv[])
{
int a = 2;
int b = 3;
cout << "Isso é um teste\n";
return func(&a, &b);
}
---
$ g++ -c -o cpp.o cpp.cpp
In file included from cpp.cpp:2:0:
c.h:5:25: error: expected ‘,’ or ‘...’ before ‘new’
regards
Lucas De Marchi