Howdy, Stranger!

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

Categories

C type variables in C++ program

TKellmannTKellmann Member Posts: 3
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

  • davidisladavidisla Member Posts: 12
    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.
    :

  • Justin BibJustin Bib USAMember Posts: 0

    _ \ http://forcoder.org \ free video tutorials and ebooks about | Assembly C MATLAB PL/SQL R PHP Visual Basic Ruby C++ Python Objective-C Perl Visual Basic .NET JavaScript Swift C# Go Delphi Scratch Java Prolog D FoxPro ABAP Apex Logo Ada Lisp Crystal Scheme F# ML Fortran Hack SAS Bash LabVIEW Lua COBOL Kotlin Rust Scala Alice Dart VBScript Clojure Transact-SQL Awk Erlang Julia | ___

Sign In or Register to comment.