473,327 Members | 2,112 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,327 software developers and data experts.

Converting C functions into c++ functions...

Hi everyone. I have used some functions like gotoxy() for ages, they would work perfectly under Turbo C and were easy to use... Had no problems, nothing! But since i am using Dev c++ 4.9.9.2, those functions are not available. I am currently needing them for my programs (which are made under dev c++) and can't get to make it work.

I have tried to make an executable by using TurboC which (having been given command-line parameters) would go to the position in console specified. Then, i made a program in dev-c++ in which you just wrote 2 numbers and the program would run the c executable with the parameters given... A real hard work (had to make the numbers into char array and join loads of char arrays)... But when i got to the end and compiled, the program crashed, a windows error message would appear and say that the program had to be closed, but what surprises me is that it crashes after finishing that function (all the code for the gotoxy is in a function). If i turn the line into a comment it does not crash or anything. I do not use any global variables so i'm really confused.

So after this hard work i want to ask you whether you know about any library or anything able to solve this kind of problems, so that i can use c functions??


Any help would be very appreciated.
Kind Regards,

John Paul (or "Juan Pablo" as my friends say...)
Jun 17 '07 #1
3 1486
weaknessforcats
9,208 Expert Mod 8TB
So after this hard work i want to ask you whether you know about any library or anything able to solve this kind of problems, so that i can use c functions??
This sounds like a C++ mangling issue. C++, becuse of function overloading, has to convert function name plus their argument types into a unique name for the linker. To do this the C++ compilers encode the function name plus the arguments into a cryptic name that varies by compiler.

You say this worked in C.

So I would make a C++ header file that tells the complier to not mangle th function name:

Expand|Select|Wrap|Line Numbers
  1. extern "C" gotoxy();
  2.  
Build using this in your C++ heade and add the C library to your link.

The extern "C" tells the compiler that the function name comes from C and must be used by the C name only.
Jun 17 '07 #2
This sounds like a C++ mangling issue. C++, becuse of function overloading, has to convert function name plus their argument types into a unique name for the linker. To do this the C++ compilers encode the function name plus the arguments into a cryptic name that varies by compiler.

You say this worked in C.

So I would make a C++ header file that tells the complier to not mangle th function name:

Expand|Select|Wrap|Line Numbers
  1. extern "C" gotoxy();
  2.  
Build using this in your C++ heade and add the C library to your link.

The extern "C" tells the compiler that the function name comes from C and must be used by the C name only.
Sounds like it will work
Jun 19 '07 #3
gpraghuram
1,275 Expert 1GB
Hi,
in the header file u use add this definition
Expand|Select|Wrap|Line Numbers
  1. #ifdef _cplusplus
  2. extern "C" {
  3. #endif
  4.  
  5. /*your declaratons */
  6.  
  7.  
  8. #ifdef _cplusplus
  9. }
  10. #endif
  11.  
Check the #ifdef name (i am not sure whether it is __cplusplus or _cplusplus

Raghuram
Jun 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: shang | last post by:
Hi! I am trying to find a function that converts a string into a double or a long double number. I found atod() but I don't know which library I have to include to use it. Could someone help me? ...
8
by: Rick | last post by:
Hi, Does C have some handy functions to convert chars, ints and floats to bit arrays? I need to store that stuff binary so a few functions would be great. Converting chars and ints isn't...
2
by: Jerry chapman | last post by:
Several years ago I wrote a console program in Visual C++, which I am still using. In converting this program to C#, I have encountered the following problems: 1. I build my console display in...
9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
9
by: Terry | last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces. One of the major uses is to be able to split out Read-only access to an obect. Let me give you a simple (contrived)...
116
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused...
2
by: CoreyWhite | last post by:
Problem: You have numbers in string format, but you need to convert them to a numeric type, such as an int or float. Solution: You can do this with the standard library functions. The...
4
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
0
by: Terry Reedy | last post by:
A. Joseph wrote: These are number representation systems that can be applied to or used with integral, rational (numberator,denominator), and 'point' numbers. Try Wikipedia or any search...
4
by: screamer81 | last post by:
Hello, I've a SDK functions description for a scanner and I try to convert unmanaged DLL C++ functions to c#. I converted all except one of them. This function is getting a struct parameter. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.