C type variables in C++ program

Hi there!

I got a problem using c-code in my c++ program:

in "odeint.c" I defined:
extern int kmax;

in "global.cpp" I defined:
int kmax;

which gives me the linking error:
unresolved external symbol _kmax...

if I try in "odeint.c":
int kmax;

and in "global.cpp":
kmax=1000;

The value of kmax is not changed;
it remains 0.

---

In the online-help I found a way for the opposite problem by defining:
extern "C" int kmax;
in a c++ program, but unfortunately that's the wrong way round...

Thanks for any advice,
Timo.

Comments

  • Hi Timo

    You must rename your file odeint.c to odeint.cpp

    odeint.cpp
    ------------------

    extern int kmax;

    global.cpp
    ------------------
    int kmax;

    :)


    : Hi there!
    :
    : I got a problem using c-code in my c++ program:
    :
    : in "odeint.c" I defined:
    : extern int kmax;
    :
    : in "global.cpp" I defined:
    : int kmax;
    :
    : which gives me the linking error:
    : unresolved external symbol _kmax...
    :
    : if I try in "odeint.c":
    : int kmax;
    :
    : and in "global.cpp":
    : kmax=1000;
    :
    : The value of kmax is not changed;
    : it remains 0.
    :
    : ---
    :
    : In the online-help I found a way for the opposite problem by defining:
    : extern "C" int kmax;
    : in a c++ program, but unfortunately that's the wrong way round...
    :
    : Thanks for any advice,
    : Timo.
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion