C language is easy to make mistakes and easy to forget

Memory unit:

  • Byte。1Byte=8bits。

Pointer array and array pointer:

  • Pointer array: int* p[n], an array of pointers, storing n addresses;
  • Array pointer: int (*p)[n], the pointer of the array, save 1 address.

Structure struct:

  • Memory alignment: The memory alignment of the previous variable is an integer multiple of the variable memory behind, and the entire struct is an integer multiple of the maximum variable memory.

Union:

  • The same memory location stores different data types, and only one member can have a value at any time. The memory length is determined by the longest member.

so dynamic library and compilation:

  • The dynamic library is .dll under windows and .so under linux. The static library is .lib under windows and .a under linux.
  • Source files (.h, .cpp, etc.)
    • -->Pre-compilation: complete macro replacement, file import, and remove blank lines, comments, etc.
    • -->Compile: Process the preprocessed code into assembly code.s. Code inspection, code optimization, assembly code generation.
    • -->Assembly: Convert .s to machine code 01 sequence .o file.
    • -->Link
    • -->Executable file
# 生成目标文件.o
gcc -c test.c
# 生成动态库,-shared代表生成动态库,-fPIC代表使用相对地址
gcc -shared -fPIC -o libtest.so test.o

 

 

 

Guess you like

Origin blog.csdn.net/weixin_36389889/article/details/106471687