Using a C++ static lib through a C program.

This is a discussion on Using a C++ static lib through a C program. within the C Programming forums, part of the General Programming Boards category; Greetings, I am working on a project that is being developed in C. I have found a C++ static library ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    4

    Using a C++ static lib through a C program.

    Greetings,

    I am working on a project that is being developed in C. I have found a C++ static library that I would like to use with it.

    What would be the best way to handle this?

    One way I've got it to work is to rename all the C source files to .cpp. Is this an acceptable way to handle the situation?

    Thanks in advance.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Is this an acceptable way to handle the situation?
    Not if you want to keep working with C. Usually when you change the extension to match C++ the compiler will think that's what you want and compile as C++. The best way to handle the situation is to either find the same library for C, or modify the current library (if the source is included) so that it can be compiled as straight C. Mixing C with C++ can and is often done, but mixing C++ with C is iffy at best.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking errors with static var
    By Elysia in forum C++ Programming
    Replies: 8
    Last Post: 10-27-2007, 05:24 PM
  2. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 06:48 PM
  3. problem about static Lib and function pointer
    By wu7up in forum C Programming
    Replies: 3
    Last Post: 02-24-2003, 08:34 AM
  4. Replies: 2
    Last Post: 05-10-2002, 04:16 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

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