关于技术的一些奇奇怪怪的知识点

include

include本质就是把include的文件内容拷贝到当前插入include的位置.
所以就可以有一些奇怪的用法:
a.h

1
2
3
4
5
6
#ifndef _AAA
#define _AAA
else:
printf("1\n");

#endif

a.c

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>

void main(void){
int a = 0;
if(a==1){
...
}
#include "a.h"
return;
}

c的结构体

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct new1 {
int a1;
};

struct a2 {
struct new1;// 这个位置我们没有给结构体变量名
int a22;
};


int main() {
struct a2 b1;
b1.a1;// 但是, 我们可以直接引用结构体的成员!
return 0;
}

int 到 size_t

对于x64, 无论是gcc还是msvc, 编译int a=-1;size_t new = (size_t)a;的结果, new都是0xffffffffffffffff.