473,795 Members | 3,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert C code chunk in a big C++ program

Hi,

I don't know if it is better to post this question to a C or C++
group, so my apologies.

My general question:

I have a very big C++ program (Main.cpp) which compiles on machine X
with compiler XA++.

I also have a function whose source code (function.c) in C (not C++)
compiles on machine X with compiler XBcc.

XA++ and XBcc are compilers from different companies.

On machine Y I can do:

1- compilation of Main.cpp to object file Main.o using compiler Y++
2- compilation of function.c to objetc file function.o using compiler
Ycc

Compilers Y++ and Ycc come from the same company. "Y" could be for
instance the GNU compiler so we would have g++ and gcc.

3- Main.o sends input data to function.o and function.o returns
calculated data to Main.o. Now I link in some way Main.o with
function.o and create Program_in_Y.ex e.

My general question is if I can do the same procedure in machine X.
Perhaps the same question is if objects created with different
compilers on the same machine can link in some way and create an
executable or binary file.

Thanks.

May 19 '07
16 2887
Ernie Wright wrote:
Ian Collins wrote:
>It is standard practice for all native C compilers to use the came
calling conventions on a particular machine. A C compiler that didn't
would be next to useless as it wouldn't be able to generate code that
used the native libraries.

One might think so, but I know of at least one counterexample, and it
certainly wouldn't surprise me if there were others.

The Win32 API contains no function that returns a floating-point value,
so no convention arose about how to do that. Given the following,
So what about strtod() and friends?

--
Ian Collins.
May 19 '07 #11
po*****@gmail.c om wrote:
On May 19, 4:02 am, horacius....@gm ail.com wrote:
.... snip and jumping in. This is to horacius.
>>
I have a very big C++ program (Main.cpp) which compiles on machine
X with compiler XA++.

I also have a function whose source code (function.c) in C (not
C++) compiles on machine X with compiler XBcc.

XA++ and XBcc are compilers from different companies.

On machine Y I can do:

1- compilation of Main.cpp to object file Main.o using compiler Y++
2- compilation of function.c to objetc file function.o using
compiler Ycc

Compilers Y++ and Ycc come from the same company. "Y" could be for
instance the GNU compiler so we would have g++ and gcc.

3- Main.o sends input data to function.o and function.o returns
calculated data to Main.o. Now I link in some way Main.o with
function.o and create Program_in_Y.ex e.

My general question is if I can do the same procedure in machine X.
Perhaps the same question is if objects created with different
compilers on the same machine can link in some way and create an
executable or binary file.
This is really a C++ question, and should be answered on
comp.lang.c++. However the secret is in the use of __cplusplus__
in the header file for function.c. However you also need to check
the documentation of your compilers.

--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfoc us.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

May 20 '07 #12
CBFalconer <cb********@yah oo.comwrites:
[...]
This is really a C++ question, and should be answered on
comp.lang.c++. However the secret is in the use of __cplusplus__
in the header file for function.c. However you also need to check
the documentation of your compilers.
It's __cplusplus, not __cplusplus__.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 20 '07 #13
Ian Collins wrote:
Ernie Wright wrote:
>>
The Win32 API contains no function that returns a floating-point
value, so no convention arose about how to do that.

So what about strtod() and friends?
Not sure what you're asking. They aren't part of the Win32 API.

In general, compilers for Windows provide their own C runtime libraries.
It'd be pretty unusual for code compiled by X to be linked to Y's
runtime, and I wouldn't automatically assume that it could be done.

- Ernie http://home.comcast.net/~erniew
May 20 '07 #14
Ernie Wright wrote:
Ian Collins wrote:
>Ernie Wright wrote:
>>>
The Win32 API contains no function that returns a floating-point
value, so no convention arose about how to do that.

So what about strtod() and friends?

Not sure what you're asking. They aren't part of the Win32 API.

In general, compilers for Windows provide their own C runtime libraries.
It'd be pretty unusual for code compiled by X to be linked to Y's
runtime, and I wouldn't automatically assume that it could be done.
I see. I didn't realise that, I'm used to operating systems which have
their own standard libraries.

--
Ian Collins.
May 20 '07 #15
ho**********@gm ail.com wrote:
I have a very big C++ program (Main.cpp) which compiles on machine X
with compiler XA++.

I also have a function whose source code (function.c) in C (not C++)
compiles on machine X with compiler XBcc.

XA++ and XBcc are compilers from different companies.
Does XA++ have a C mode for compiling?

--
Thad
May 20 '07 #16
Doing some investigation I checked that using GNU compiler for C++ and
C with function wrappers, this is feasible.

Thanks.


On 19 mayo, 13:02, horacius....@gm ail.com wrote:
Hi,

I don't know if it is better to post this question to a C or C++
group, so my apologies.

My general question:

I have a very big C++ program (Main.cpp) which compiles on machine X
with compiler XA++.

I also have a function whose source code (function.c) in C (not C++)
compiles on machine X with compiler XBcc.

XA++ and XBcc are compilers from different companies.

On machine Y I can do:

1- compilation of Main.cpp to object file Main.o using compiler Y++
2- compilation of function.c to objetc file function.o using compiler
Ycc

Compilers Y++ and Ycc come from the same company. "Y" could be for
instance the GNU compiler so we would have g++ and gcc.

3- Main.o sends input data to function.o and function.o returns
calculated data to Main.o. Now I link in some way Main.o with
function.o and create Program_in_Y.ex e.

My general question is if I can do the same procedure in machine X.
Perhaps the same question is if objects created with different
compilers on the same machine can link in some way and create an
executable or binary file.

Thanks.

May 21 '07 #17

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

Similar topics

26
2945
by: Michael Strorm | last post by:
Hi! I posted a message a while back asking for project suggestions, and decided to go with the idea of creating an adventure game (although it was never intended to be a 'proper' game, rather an excuse to write- and learn- some C++). To cut a long story short, I wrote a fair chunk of it, but realised that it's... not very good. Okay, it's my first "proper" C++ program, so that's no big deal, but I don't want to waste more time working...
9
3462
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM, VARCHAR(10) WO.PROBLEMCODE, VARCHAR(8)
9
4244
by: adi | last post by:
Hi all, Hope there is a quick fix for this: I am inserting data from one table to another on the same DB. The insert is pretty simple as in: insert into datatable(field1, field2, field3) select a1, a2, a3 from temptable...
2
3161
by: terpatwork | last post by:
Hi, (1) I have an access form that allows users to enter data, and when they click a button, the OnClick code that I've written uses a SQL INSERT statement to insert the data into the database. I come from a web programming background, so please forgive me if there is some better approach to use in Access to accomplish this. My problem is that when users type in more than 512 characters (in a Memo field) and click the button, only the...
9
2406
by: zerro | last post by:
Hello, I try to understand heap overflows (under Linux), but can not understand one thing with freeing memory allocated with malloc(). Here it comes: I have a program called 1.c: main() { char *a, *b, *c, *d, *e; a = malloc(8);
4
3141
by: dragoncoder | last post by:
Hello all, I have the following code. Plesae have a look. #include <iostream> #include <string> #include <map> #include <cstdlib> using namespace std;
2
4189
by: mirandacascade | last post by:
O/S: Win2K Vsn of Python: 2.4 Example: <a> <b createAnotherWhenCondition="x"> <c>text for c</c> <d>text for d</d> </b>
15
395
by: horacius.rex | last post by:
Hi, I don't know if it is better to post this question to a C or C++ group, so my apologies. My general question: I have a very big C++ program (Main.cpp) which compiles on machine X with compiler XA++.
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10435
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.