Thread: How to call C function from C++

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    11

    How to call C function from C++

    How do we call a C function from a C++ program .

    Thanx in anticipation

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The same way you call a C++ function? Besides, this is a C++ question, and conveniently, there is a board for that!

    Quzah.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Code:
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    void my_c_function ( int );
    
    #ifdef __cplusplus
    }
    #endif
    Then you just call it
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM