Thread: Including C++ headers (and functions) to a C-file

  1. #1
    torbjorn
    Guest

    Question Including C++ headers (and functions) to a C-file

    Hi!

    I have a C++ header-file and a C++ source-file which I would like to include and use in a C-file.

    How can I get around this without converting my C-code to C++?

    I can write

    Code:
    extern "C"
    {
    	#include <GL/gl.h>
    	#include <GL/glut.h>
    	#include <GL/glaux.h>
    }
    to include C-code into C++ files, but I need to go the other way around... Can I do this without having to compile dll-files/lib-files of my C++ code? Or without having to convert my C-file to C++?

    Thanks!

    Best regards,
    Torbjørn

  2. #2
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    I haven't tried this but wouldn't
    extern "C++"{..} do the trick?

    /btq
    ...viewlexx - julie lexx

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    11
    btq: I get this error when using extern "C++":
    Code:
    error C2059: syntax error : 'string'
    Salem: I think you gave me the answer :-) Check out http://www.parashift.com/c++-faq-lit....html#faq-31.6

    Thanks!

    Torbjørn

  4. #4
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    if you haven't solved the problem yet maybe this could be helpful

    /btq
    ...viewlexx - julie lexx

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    11
    Thanks, btq! Now I must be able to make it work :-)

    Torbjørn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Setting up headers, functions etc.
    By DrSnuggles in forum C++ Programming
    Replies: 22
    Last Post: 10-24-2007, 01:37 PM
  2. Searching Binary Files for a Pattern
    By CaptainMorgan in forum C Programming
    Replies: 16
    Last Post: 06-17-2007, 06:04 PM
  3. #include header files or .cpp files?
    By DoctorX in forum C++ Programming
    Replies: 3
    Last Post: 12-23-2006, 12:21 PM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  5. Where to find the code for Header File FUnctions
    By vsriharsha in forum C Programming
    Replies: 1
    Last Post: 04-02-2002, 12:37 PM