1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

non-system C function

Discussion in 'C' started by heena.mca, Mar 13, 2008.

  1. heena.mca

    heena.mca New Member

    Joined:
    Feb 14, 2008
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    How can I call a non-system C function f(int,char,float) from my C++ code?
     
  2. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    just as from C function.

    One thing c++ mangling will happen. Just define extern C.
     
  3. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    // Suppose this is your c++ file code

    extern "C"
    {
    //Include that file also where definition of f is written
    f(int , char , float );
    }

    int main()
    {
    f(1, 'g', 1.1); /// No Name mangling happen
    ...
    }
     

Share This Page