gpt4 book ai didi

宏观困惑

转载 作者:行者123 更新时间:2023-12-04 11:15:27 26 4
gpt4 key购买 nike

下面的代码可以正常工作

#define open {
#define close }
#include<stdio.h>
#define int char

main()
open
int a ;
printf("This is testing code" );
close

但是如果我换行

#include<stdio.h>
#define int char

作为

#define int char 
#include<stdio.h>

它会抛出很多这样的错误

In file included from /usr/include/stdio.h:36,
from print.c:19:
/usr/include/bits/types.h:35: error: both 'short' and 'char' in declaration specifiers
/usr/include/bits/types.h:37: error: both 'long' and 'char' in declaration specifiers
/usr/include/bits/types.h:42: error: both 'short' and 'char' in declaration specifiers
/usr/include/bits/types.h:43: error: both 'short' and 'char' in declaration specifiers
.................................................
so and so

实际上 stdio.h 中发生了什么?

最佳答案

定义了short intlong int等类型的变量,通过define改成short char显然失败了> 和 long char

重新定义基本的 C 类型通常不是一个好主意。

关于宏观困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2408855/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com