鱼C论坛

 找回密码
 立即注册
查看: 3622|回复: 26

[吹水] 编译这个代码,你的编译器就会发生奇妙的反应~【C++之系统恶搞】

[复制链接]
发表于 2022-12-19 13:05:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 zhangjinxuan 于 2022-12-20 13:19 编辑

创建一个文件,命名为 g.cpp

文件内容:
  1. #include "g.cpp"
  2. #include "g.cpp"
  3. #include "g.cpp"
  4. #include "g.cpp"
  5. #include "g.cpp"
  6. #include "g.cpp"
  7. #include "g.cpp"
  8. #include "g.cpp"
  9. #include "g.cpp"
  10. #include "g.cpp"
  11. #include "g.cpp"
  12. #include "g.cpp"
  13. #include "g.cpp"
  14. #include "g.cpp"
  15. #include "g.cpp"
  16. #include "g.cpp"
  17. #include "g.cpp"
  18. #include "g.cpp"
  19. #include "g.cpp"
  20. #include "g.cpp"
  21. #include "g.cpp"
  22. #include "g.cpp"
  23. #include "g.cpp"
  24. #include "g.cpp"
  25. #include "g.cpp"
  26. #include "g.cpp"
  27. #include "g.cpp"
  28. #include "g.cpp"
  29. #include "g.cpp"
  30. #include "g.cpp"
  31. #include "g.cpp"
  32. #include "g.cpp"
  33. #include "g.cpp"
  34. #include "g.cpp"
  35. #include "g.cpp"
  36. int main() {
  37. }
复制代码

这个 #include "g.cpp" 你爱填多少就填多少,填的越多你的编译器越快乐~

最终,你可能会得到长约15000行的离谱报错(windows dev-cpp g++):
  1. 1                g.cpp        In file included from g.cpp
  2. 1                g.cpp                         from g.cpp
  3. 1                g.cpp                         from g.cpp
  4. 1                g.cpp                         from g.cpp
  5. 1                g.cpp                         from g.cpp
  6. 1                g.cpp                         from g.cpp
  7. 1                g.cpp                         from g.cpp
  8. 1                g.cpp                         from g.cpp
  9. 1                g.cpp                         from g.cpp
  10. 1                g.cpp                         from g.cpp
  11. 1                g.cpp                         from g.cpp
  12. 1                g.cpp                         from g.cpp
  13. 1                g.cpp                         from g.cpp
  14. 1        17        g.cpp        [Error] #include nested too deeply
  15. 2        17        g.cpp        [Error] #include nested too deeply
  16. 3        17        g.cpp        [Error] #include nested too deeply
  17. 4        17        g.cpp        [Error] #include nested too deeply
  18. 5        17        g.cpp        [Error] #include nested too deeply
  19. 6        17        g.cpp        [Error] #include nested too deeply
  20. 7        17        g.cpp        [Error] #include nested too deeply
  21. 8        17        g.cpp        [Error] #include nested too deeply
  22. 9        17        g.cpp        [Error] #include nested too deeply
  23. 10        17        g.cpp        [Error] #include nested too deeply
  24. 11        17        g.cpp        [Error] #include nested too deeply
  25. 12        17        g.cpp        [Error] #include nested too deeply
  26. 13        17        g.cpp        [Error] #include nested too deeply
  27. 14        17        g.cpp        [Error] #include nested too deeply
  28. 15        17        g.cpp        [Error] #include nested too deeply
  29. 16        17        g.cpp        [Error] #include nested too deeply
  30. 17        17        g.cpp        [Error] #include nested too deeply
  31. 18        17        g.cpp        [Error] #include nested too deeply
  32. 19        17        g.cpp        [Error] #include nested too deeply
  33. 20        17        g.cpp        [Error] #include nested too deeply
  34. 21        17        g.cpp        [Error] #include nested too deeply
  35. 22        17        g.cpp        [Error] #include nested too deeply
  36. 23        17        g.cpp        [Error] #include nested too deeply
  37. 24        17        g.cpp        [Error] #include nested too deeply
  38. 25        17        g.cpp        [Error] #include nested too deeply
  39. 26        17        g.cpp        [Error] #include nested too deeply
  40. 27        17        g.cpp        [Error] #include nested too deeply
  41. 28        17        g.cpp        [Error] #include nested too deeply
  42. 29        17        g.cpp        [Error] #include nested too deeply
  43. 30        17        g.cpp        [Error] #include nested too deeply
  44. 31        17        g.cpp        [Error] #include nested too deeply
  45. 32        17        g.cpp        [Error] #include nested too deeply
  46. 33        17        g.cpp        [Error] #include nested too deeply
  47. 34        17        g.cpp        [Error] #include nested too deeply
  48. 35        17        g.cpp        [Error] #include nested too deeply
  49. 22                g.cpp        In file included from g.cpp
  50. 【此处省略约15000行……】
复制代码


完整报错
这是一个长的离谱的编译报错!.zip (3.27 KB, 下载次数: 6)
不难发现,这个和小甲鱼老师说的“递归结构体”有相似之处,属是你中有我,我中有你,就无限递归啦~

大家在之后搞工程或者做什么的也要注意,不要出现 include 本身的情况,免得这么多报错把软件卡死了 (编译完后我的软件真崩溃了)

此外呢,大家还能想出更离谱的编译报错吗

附:鱼油投稿( tommyyu ):
  1. #include <stdlib.h>
  2. int main()
  3. {
  4.         while(1) system("start g.exe");      
  5. }
复制代码

把这个保存为g.cpp,编译出g.exe,然后运行,然后电脑就会特别快乐

这个就不要轻易尝试了

评分

参与人数 1荣誉 +1 鱼币 +1 收起 理由
雪山之神 + 1 + 1 感谢楼主无私奉献!

查看全部评分

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-12-19 13:09:15 | 显示全部楼层
我没有编译报错,不过有一个可以让电脑快乐的程序
  1. #include <stdlib.h>
  2. int main()
  3. {
  4.         while(1) system("start g.exe");       
  5. }
复制代码
把这个保存为g.cpp,编译出g.exe,然后运行,然后电脑就会特别快乐
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-19 13:10:24 | 显示全部楼层
tommyyu 发表于 2022-12-19 13:09
我没有编译报错,不过有一个可以让电脑快乐的程序把这个保存为g.cpp,编译出g.exe,然后运行,然 ...


哈哈哈哈,真不错!

马上,我要重启了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-19 13:14:52 From FishC Mobile | 显示全部楼层
tommyyu 发表于 2022-12-19 13:09
我没有编译报错,不过有一个可以让电脑快乐的程序把这个保存为g.cpp,编译出g.exe,然后运行,然 ...

电脑崩了,现在在用手机
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-19 13:16:25 | 显示全部楼层
zhangjinxuan 发表于 2022-12-19 13:14
电脑崩了,现在在用手机

建议把这个程序设为开机启动项
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-19 13:17:04 | 显示全部楼层
tommyyu 发表于 2022-12-19 13:16
建议把这个程序设为开机启动项

我现在电脑黑了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-19 13:18:36 | 显示全部楼层
tommyyu 发表于 2022-12-19 13:16
建议把这个程序设为开机启动项

我的电脑居然还活着!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-19 13:18:51 | 显示全部楼层

重启成功了么
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-19 13:19:46 | 显示全部楼层

成功了,我的电脑居然没有逝
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-19 13:37:55 | 显示全部楼层
zhangjinxuan 发表于 2022-12-19 13:19
成功了,我的电脑居然没有逝

我刚刚也逝了一下,程序根本关不掉,然后电脑就黑屏了,接下来自己关机了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-19 16:50:59 | 显示全部楼层
tommyyu 发表于 2022-12-19 13:37
我刚刚也逝了一下,程序根本关不掉,然后电脑就黑屏了,接下来自己关机了

Linux 不起作用

久了会提示什么 Cannot fork,看来 Linux 的保护机制还是很强~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-20 12:57:27 | 显示全部楼层
我的也不行了

都50000多行了

还在增加

C  之系统恶搞.jpg
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-20 12:59:38 | 显示全部楼层
哈哈哈
我的编译器崩了
我关掉了
屏幕截图 2022-12-20 125853.jpg
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-20 13:03:59 | 显示全部楼层
tommyyu 发表于 2022-12-19 13:09
我没有编译报错,不过有一个可以让电脑快乐的程序把这个保存为g.cpp,编译出g.exe,然后运行,然 ...

我成功的崩了,现在刚刚重启回来
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-20 13:16:34 | 显示全部楼层
zsy0226 发表于 2022-12-20 12:59
哈哈哈
我的编译器崩了
我关掉了

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-20 13:27:06 | 显示全部楼层
zsy0226 发表于 2022-12-20 13:03
我成功的崩了,现在刚刚重启回来

这个程序才是王中王,对吧
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-20 13:36:51 | 显示全部楼层
zhangjinxuan 发表于 2022-12-20 13:27
这个程序才是王中王,对吧

我感觉如果给这个程序弄个开机自启动这个电脑就废了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-20 13:40:16 | 显示全部楼层
tommyyu 发表于 2022-12-20 13:36
我感觉如果给这个程序弄个开机自启动这个电脑就废了

肯定,很废CPU和内存
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-20 13:42:42 | 显示全部楼层
zhangjinxuan 发表于 2022-12-20 13:40
肯定,很废CPU和内存

我上次运行这玩意的时候还写了一个按下某键,让电脑自动关机的程序(避免电脑废掉),结果这个关机程序也没法执行
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-12-20 13:46:40 | 显示全部楼层
tommyyu 发表于 2022-12-20 13:42
我上次运行这玩意的时候还写了一个按下某键,让电脑自动关机的程序(避免电脑废掉),结果这个关机程序也 ...

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-24 19:19

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表