tags:

views:

32

answers:

1

Hi,

I create a simple test.cpp file in my Xcode project.

#include "MyTest.h"

#include <stdio.h>

int main(int argc, char** argv) {
    printf ("Calling MyTest Main\n");
}

It compiles. I think I need to create a Target and Executables before I can launch in XCode. But I need some help with these questions: 1. What kind of Target i should create for my simple .cpp file? It is not a GUI application. 2. How to specify this main in test.cpp to be the starting point of my Target and Executable?

Thank you.

A: 

1) You probably want a Command Line Tool application.

2) When you launch your tool, the mach kernel calls the start() function in the C Runtime Library, which invokes main() with the count of arguments (argc) and an array of argument string pointers (argv). So the main() that you show above is what will run.

You can use a special linker command to designate one of your own functions to be run instead of start(), but almost nobody does.

cdespinosa