find c files within c++ project

Discussion in 'C++' started by ahso, Oct 10, 2011.

  1. ahso

    ahso Guest

    Hi
    I get tons of: undefined references so i suspect to have
    some c header files which need: extern "C"
    So how can I find those? Or can i put this in every header?
    Thanks
     
    ahso, Oct 10, 2011
    #1
    1. Advertisements

  2. On 10.10.11 13.04, ahso wrote:
    > I get tons of: undefined references so i suspect to have
    > some c header files which need: extern "C"


    Are you sure?

    > So how can I find those? Or can i put this in every header?
    > Thanks


    Tracking a few examples of your undefined symbols to their root will be
    more helpful than firing haphazardly with the shotgun on header files.

    The extern "C" C++ guards are useful if and only if C code sould be used
    within C++ code.


    Marcel
     
    Marcel Müller, Oct 10, 2011
    #2
    1. Advertisements

  3. ahso

    Jorgen Grahn Guest

    On Mon, 2011-10-10, ahso wrote:
    > Hi
    > I get tons of: undefined references so i suspect to have
    > some c header files which need: extern "C"
    > So how can I find those?


    They are only C header files if their implementation is compiled
    as C code rather than C++. Surely your Makefile (or whatever you use
    for a build system) can tell you what it compiles and how.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Oct 10, 2011
    #3
  4. ahso

    ahso Guest

    LIBS += -llua -lBulletDynamics -lBulletCollision -lLinearMath -
    lcurl -lopenal -lalut

    Those are the Qtcreator libs. ~400 undefined references errors so
    something very basic is very wrong.
    Nobody can help how to approach such?
     
    ahso, Oct 10, 2011
    #4
  5. ahso

    Nobody Guest

    On Mon, 10 Oct 2011 04:04:00 -0700, ahso wrote:

    > I get tons of: undefined references so i suspect to have
    > some c header files which need: extern "C"
    > So how can I find those? Or can i put this in every header?


    If you're including C headers which don't have the C++ "guards", then you
    can do:

    extern "C" {
    #include <foo.h>
    }

    This usually works, but there are things which can appear in a C header
    which make it invalid as C++ (e.g. use of C++-specific keywords as
    identifiers).
     
    Nobody, Oct 10, 2011
    #5
  6. Nobody <> wrote:
    > On Mon, 10 Oct 2011 04:04:00 -0700, ahso wrote:
    >
    >> I get tons of: undefined references so i suspect to have
    >> some c header files which need: extern "C"
    >> So how can I find those? Or can i put this in every header?

    >
    > If you're including C headers which don't have the C++ "guards", then you
    > can do:
    >
    > extern "C" {
    > #include <foo.h>
    > }


    That's such a "Paulish" answer that I'm pretty sure you are him.
     
    Juha Nieminen, Oct 11, 2011
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raterus
    Replies:
    2
    Views:
    958
    Joe Fallon
    Apr 28, 2004
  2. Optimize ASP.Net
    Replies:
    1
    Views:
    549
    Scott Allen
    May 6, 2005
  3. Wybo Dekker
    Replies:
    1
    Views:
    497
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    510
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    975
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page