Development Tool on Mac OS X-xcode

Source: Internet
Author: User
Development Tool on Mac OS X-xcode
Yang Xiaohua (normalnotebook@126.com)

1. xcode Introduction
I remember when I browsed the news about the dragon core, the dragon core maker once said that whether a CPU is popular or whether a corresponding integrated development environment exists. This is not the case for an operating system. The most familiar developer on Windows systems is Visual Studio and eclipse. I am afraid VI and Emacs are the most widely used developers in Linux. Many Linux vendors have also launched an eclipse-based integrated development environment on the platform. After the transformation, only the names of different vendors are different.
Mac OS X is a UNIX operating system. The most basic compilation and debugging tools are GCC and GDB. Mac OS X pre-installed on Apple machines does not have a development environment. The xcode tool must be installed separately to provide development capabilities. Xcode can be downloaded from the apple website.
First, let's see the secret of xcode:

2. Unveil the secret of xcode
Xcode is a powerful development tool that allows you to create multiple projects. :

Xcode supports multiple types of projects. Each item contains many small items.
The heart is not as good as action. Next we will create a multi-threaded console program to experience the powerful functions of xcode.

Obtain the name multithread, and the code of the display column is as follows: # include <stdio. h>
# Include <pthread. h>


Void * task1 ()
...{
Int I = 0;
For (I = 0; I <500000; I ++)
Printf ("Hello, task1! ");
}

Void * task2 ()
...{
Int I = 0;
For (I = 0; I <500000; I ++)
Printf ("Hello, task2! ");
}


Int main (INT argc, const char * argv [])... {
// Insert code here...

Pthread_t threada, threadb;
Printf ("Hello, world! ");
Pthread_create (& threada, null, task1, null );
Pthread_create (& threada, null, task2, null );
Pthread_join (threada, null );
Pthread_join (threadb, null );

Return 0;
}

After compiling the program, start compiling and click the build option in the [Build] menu. Unlike Visual Studio and eclipse, if a compilation error occurs, no form is displayed and an error is reported, only a few errors and warnings are displayed in the status bar. If you want to know where the error is, you can click the errors and warnings option in the left column to view the file where the error is located, the number of lines, and the cause of the error.
Xcode provides a variety of debugging methods, which can be debugged on a GUI or through a terminal. The terminal debugging method is the normal GDB interface ,:

The corresponding graphic interface is:

In GDB, you can set breakpoints, observation points, and exception points. However, the xcode tool does not provide a method for setting observation points. At the same time, it also provides a method to add breakpoints in batches ,:

Using xcode to build a project saves us the trouble of writing makefile. This is similar to Visual Studio.
OK. Here is the basic usage of the xcode tool. The next article describes the performance tools provided by xcode. Now multi-threaded programming has become a trend. We will use these tools to analyze multi-threaded programming.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.