这里面最容易迷惑的可能要算void _Z6my_funv(void);函数了,看到下面的命令后,相信就没什么问题了。
百度网盘下载地址:
https://pan.baidu.com/s/1_-IznMWL3z1CROziiD6mCw
//test87.c
#include <stdio.h>
void chstr(void);
void _Z6my_funv(void);
#define RENAME(name) _Z7##name##v(void);
void RENAME(my_fun1);
typedef struct My_struct {
char a;
}My_struct;
#define Test(x) test##x
#define MyStr(str) #str
#define Mtest(type, name) type my##name
#define DD(name, type) type##name
#define DDD(type, name) type##name##_abc
void test0(void) {
printf("I am test0\n");
}
char s[] = "NEWCONST";
char const *str = s;
int main(void) {
printf("All is starting here.\n");
test0();
Test(0)();
printf(MyStr(Hello!));
Mtest(int, 1);
my1 = 15;
printf("%x\n", &my1);
printf("value name is %d\n", my1);
DD(_struct, My) aaa;
int DDD(int, val);
_Z6my_funv();
printf("\n");
printf("%x\n", str);
chstr();
printf("%s\n", str);
printf("%x\n", str);
_Z7my_fun1v();
}
//test86.cpp
#include <iostream>
using namespace std;
//extern "C" {
extern char s[];
void my_fun(void) {
int aaa = 0xffff;
// cin >> aaa;
cout <<endl;
cout << aaa;
cout <<endl;
cout << s;
}
void my_fun1(void) {
cout << "I am my_fun1";
cout <<endl;
cout << s;
}
//}
#test85.s
.globl _chstr
.extern _str, _s
_chstr: #void chstr(void);
pushl %ebx
pushl %eax
lea _str, %ebx
addl $2, (%ebx)
movl (%ebx), %eax
movb $'I', (%eax)
popl %eax
popl %ebx
ret