473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

using old c libraries

Hi,

I want to write a C++ program, but still have access to some C code
which has a bunch of utility functions I'd like to use.

My question is: Compiling with gcc, how difficult will this be? What
do I have to do to make it work?

Thanks for any comments or references,
cppaddict
Jul 22 '05 #1
3 1089
The three library headers that you may want to change in C++ are -

<stdio.h> to <cstdio>
<math.h> to <cmath>
<stdlib.h> to <cstdlib>

as they are the main differences between C++ and C in terms of
libraries.
Other than that, I guess things would be pretty fine. clc++ can
please comment on this, better.

cppaddict wrote:
Hi,

I want to write a C++ program, but still have access to some C code
which has a bunch of utility functions I'd like to use.

My question is: Compiling with gcc, how difficult will this be? What
do I have to do to make it work?

Thanks for any comments or references,
cppaddict


--

--
Rakesh Kumar
** Remove nospamplz from my email address for my real email **
Jul 22 '05 #2

"cppaddict" <he***@hello.com> wrote in message
news:a3********************************@4ax.com...
Hi,

I want to write a C++ program, but still have access to some C code
which has a bunch of utility functions I'd like to use.

My question is: Compiling with gcc, how difficult will this be? What
do I have to do to make it work?

Thanks for any comments or references,
cppaddict


You need to make sure that your C functions have C linkage. This is
something C++ understands but C doesn't, so you need to code your headers
something like this

#ifdef __cplusplus
extern "C" { // C linkage
#endif

void some_library_function(void);
int another_library_function(int, int);

#ifdef __cplusplus
} // end C linkage
#endif

The name __cplusplus will be defined when you are using a C++ compiler but
not when you are using a C compiler.

Also note use of '(void)'. C understands () as a function with a variable
number of parameters, whereas C++ understands that as a function with zero
parameters, so use (void) which both understand.

john
Jul 22 '05 #3

John Harrison <jo*************@hotmail.com> wrote in message
news:c6************@ID-196037.news.uni-berlin.de...
Also note use of '(void)'. C understands () as a function with a variable
number of parameters, whereas C++ understands that as a function with zero
parameters, so use (void) which both understand.

I think you mean, "a fixed but unspecified number of parameters."

This is in declarations, not definitions.

Brian Rodenborn
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: sbobrows | last post by:
{Whilst I think much of this is OT for this newsgroup, I think the issue of understanding diagnostics just about gets under the door. -mod} Hi, I'm a C++ newbie trying to use the Boost regex...
3
by: rjaw | last post by:
Hi there, using the udb-type2-driver on z/OS DB version 7, we have a problem getting the connection to the database. The small program we use looks like this: ...
4
by: Anthony Gallagher | last post by:
I have a bunch of libraries compiled using VC++ 6.0, and I am trying to recompile one of our projects using VC++ .NET. I get all kind of linker errors (specially in STL calls). How do I get rid of...
0
by: Phani | last post by:
Hi All, I have 3 questions here: 1) Problem creating a SPFolder object: I am trying to create a SPFolder object for a document/picture library using the following code with SOM
2
by: Good Man | last post by:
hey there i've been buiding some web apps, and using my own scripting for coding things like AJAX, XML extraction, etc. i finally took a look on the web at js libraries, and boy are there a...
2
by: Ognjen Bezanov | last post by:
Hello, I have some external C libraries I would like to use with python. I have been searching on the internet and found many such modules/bindings for libraries (e.g. Py-Lame) but have not...
3
by: amitsoni.1984 | last post by:
Hi, I wanted to solve some linear programming problems and I was trying to use IMSL C libraries. But I couldn't get how to use it. I don't know where to write the codes and how to execute them....
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
3
by: Bala | last post by:
Hello, I am trying to create a shared library on solaris. The inputs to this library is a source file and then 2 static libraries. I need to call code within the shared library in another...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.