0 basic learning ios development notes first day, ios notes first day

Source: Internet
Author: User
Tags directory create

0 basic learning ios development notes first day, ios notes first day
Shortcut for Ios operation interface

Command + c Replication

Command + v Paste

Command + a select all

Command + s save

Command + z undo

Command + x cut

Command + space Input Method Switching

Command + <-(Return key) delete all content before the cursor in the row where the cursor is located

Option key (ios) -- alt (windows) Key

Command is the Windows key on the windows keyboard.

Linux Command cd

Cd: change directory switch directory

liuzw@ubuntu:~/sunjie$ cd cliuzw@ubuntu:~/sunjie/c$ 

 

Cd ~ Or directly enter cd to switch to the current user's home directory.

liuzw@ubuntu:~/sunjie/c$ cd liuzw@ubuntu:~$

 

Cd-Undo the last cd operation

liuzw@ubuntu:~/sunjie$ cd cliuzw@ubuntu:~/sunjie/c$ cd liuzw@ubuntu:~$ cd -/home/liuzw/sunjie/cliuzw@ubuntu:~/sunjie/c$ 

 

Cd/return to the root directory

Cd .. back to parent directory

liuzw@ubuntu:~/sunjie/c$ cd ..liuzw@ubuntu:~/sunjie$ 

 

Pwd: print workdirectory to view the current working path

 

liuzw@ubuntu:~/sunjie$ pwd/home/liuzw/sunjie
Ls: list source: view resources in the current working path, including files and directories.

 

Ls-a (all) to view all resources, including hidden

 

Ls-l (list one file per line)

 

The first column circled in red indicates the resource type, where d indicates the Directory and-indicates the file.

The second column circled in red indicates the disk space used.

Mkdir: make directory create directory

 

Mkdir-p: when the parent directory does not exist, create the parent directory instead of reporting an error.

 

Touch is generally used to create an empty file echo data output variable

 

$? Indicates the execution result of the previous command, 0 indicates that the execution is correct, and others indicate that the execution is incorrect, as shown in

 

Cp: copy

Copy an object

 

Copy directory

 

 

Cat displays the file content. You can only view the file but not the directory.

 

 

 

 

Add row number when cat-n is displayed

 

C Language

The computer only recognizes 1 and 0. The programming language levels are as follows:

Machine language

Assembly Language

Advanced Language (C language)

1001,0010, 0010,1111

Mov 2 f

While if int

C language compilation process

Compilation: translation. Common compilers such as gcc

An executable file is a set of runtime environments and objects ending with. o. Link my target files with these files to form executable files.

The target file is a binary machine code file, and the executable file is also a binary machine code file. However, the target file cannot run on the machine and must be connected to the running environment to run. The executable file can be run on the machine.

Write my first c program, hello. c, hello. h.

The content of the hello. h file is as follows:

#define HELLO "helloworld"

The contents of the Hello. c file are as follows:

#include <stdio.h>#include "hello.h"int main(void){    printf(HELLO);    return 0;}

The entire compilation phase consists of four steps:

Step 1: preprocessing, Hello. c is converted to hello. I, which is generally implicitly executed.

Preprocessing command: gcc-E hello. c-o hello. I. The generated preprocessing file is as follows:

Extern void flockfile (FILE * _ stream) _ attribute _ (_ nothrow _, _ leaf __));

Extern int ftrylockfile (FILE * _ stream) _ attribute _ (_ nothrow _, _ leaf __));

Extern void funlockfile (FILE * _ stream) _ attribute _ (_ nothrow _, _ leaf __));

#943 "/usr/include/stdio. h" 3 4

#2 "hello. c" 2

#1 "hello. h" 1

#3 "hello. c" 2

Int main (void)

{

Printf ("Helloworld");

Return 0;

}

In the preprocessing phase, macro HELLO is replaced with the actual content

Step 2: Assembly stageTo convert the C language file to the assembly language file, that is, hello. I to hello. s.

Command: gcc-S hello. I-o hello. s

The contents of the hello. s file are as follows:

    .file   "hello.c"    .section   .rodata.LC0:    .string "helloworld"    .text    .globl  main    .type   main, @functionmain:.LFB0:    .cfi_startproc    pushq   %rbp    .cfi_def_cfa_offset 16    .cfi_offset 6, -16    movq    %rsp, %rbp    .cfi_def_cfa_register 6    movl    $.LC0, %edi    movl    $0, %eax    call    printf    movl    $0, %eax    popq    %rbp    .cfi_def_cfa 7, 8    ret    .cfi_endproc.LFE0:    .size   main, .-main    .ident  "GCC: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4"    .section   .note.GNU-stack,"",@progbits

Step 3: Compile the assembly language into the corresponding machine language(Binary format), that is, convert hello. s to hello. o

Command:

gcc -c hello.s -o hello.o

Use commands

objdump -d hello.o

Decompiling the hello. o file is as follows:

Hello. o: file format elf64-x86-64

Disassembly of section. text:

0000000000000000 <main>:

0: 55 push % rbp

1: 48 89 e5 mov % rsp, % rbp

4: bf 00 00 00 mov $0x0, % edi

9: b8 00 00 00 mov $0x0, % eax

E: e8 00 00 00 00 callq 13 <main + 0x13>

13: b8 00 00 00 mov $0x0, % eax

18: 5d pop % rbp

19: c3 retq

Step 4: link the hello. o file with the runtime environment to form an executable file

Command:

gcc hello.o -o hello

View the content of the hello file. Run the command objdump-d hello disassembly to view the content.

000000000040052d <main>:

40052d: 55 push % rbp

40052e: 48 89 e5 mov % rsp, % rbp

400531: bf d4 05 40 00 mov $0x4005d4, % edi

400536: b8 00 00 00 mov $0x0, % eax

40053b: e8 d0 fe ff callq 400410 <Printf @ plt>

400540: b8 00 00 00 mov $0x0, % eax

400545: 5d pop % rbp

400546: c3 retq

400547: 66 0f 1f 84 00 00 00 nopw 0x0 (% rax, % rax, 1)

40054e: 00 00

The above is the linked main function. Note the difference between the function and the unlinked function:

0000000000000000 <main>:

0: 55 push % rbp

1: 48 89 e5 mov % rsp, % rbp

4: bf 00 00 00 mov $0x0, % edi

9: b8 00 00 00 mov $0x0, % eax

E: e8 00 00 00 00 callq 13 <Main + 0x13>

13: b8 00 00 00 mov $0x0, % eax

18: 5d pop % rbp

19: c3 retq

Execute file, command./hello

If you remove return 0 from the hello. c program, the return value is not set to 0.

Liuzw @ ubuntu :~ /Sunjie/c $./a. out

Helloworldliuzw @ ubuntu :~ /Sunjie/c $ echo $?

10

Conclusion: The following commands can be directly executed in all the above compilation processes to form an executable file a. out.

, You can also add-o hello

 

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.