-
August 25th, 2010, 11:57 AM
#1
Adding a C program to an existing c++ project
Hi All,
Thanks in advance for your help. I am trying to add the source code from an existing c program to my c++ project developed in Xcode. I suspect I may be over simplifying, but I was hoping I could add the source files to my project, rename the main function in the c program and call the new function from a c++ class in my existing project. The c files compile fine, but when the program tries to link I get "symbol not found". I took a look at http://www.codeguru.com/forum/showth...source+program But adding the extern "C" to the headers doesn't help. I created a simple .h and .c file to show what I am trying to do:
temptry.h looks like:
#ifndef MY_H_
#define MY_H_
#include <stdio.h>
int my_main (int, char*);
#endif
and temptry.c look like:
#include "temptry.h"
int my_main(int argc, char *argv[]) {
printf("here\n");
}
I call my_main from my c++ class which includes "temptry.h"
the function call looks like:
my_main(numArgs, clearcutParameters);
Thanks again for any and all suggestions!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|