How to call C function from C++

This is a discussion on How to call C function from C++ within the C Programming forums, part of the General Programming Boards category; How do we call a C function from a C++ program . Thanx in anticipation...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 02: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, 06: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21