Skip to content

搞英语 → 看世界

翻译英文优质信息和名人推特

Menu
  • 首页
  • 作者列表
  • 独立博客
  • 专业媒体
  • 名人推特
  • 邮件列表
  • 关于本站
Menu

谁还需要 main() 呢?

Posted on 2023-01-21

想对后来出现做维护工作的其他程序员造成可怕的事情吗?编写不需要 main() 的 C++ 代码。然后编写没有 *有* main() 的 C++ 代码。是的。

我很久以前就提到过,在代码中称之为“幽灵般的远距离动作”,但现在看来,这似乎是一个非常冗长的演示。

相反,今晚,我提出了一个简单得多的版本。通常的免责声明适用:可能会召唤会困扰您灵魂的远古者。可能不适用于所有系统或编译器。在我给它 -O2 之前它对我不起作用,即使那样,它仍然会给出一个宏伟的段错误。

无论如何,享受邪恶吧。

 $猫hhhehehehe .cc  #include <unistd.h>   类 wat {  上市:   wat() { write(1, "wat\n", 4); } };   静态哇哇_;   // 没有主线。没有其他的。 $ g++ -O2 -Wall -nostartfiles -o hhhehehehe hhhehehehe.cc /usr/bin/ld: 警告:找不到入口符号 _start; [...] $ ./hhhehehehe  扫管笏 分段故障 $  

就是这样。

原文: http://rachelbythebay.com/w/2023/01/20/mainless/

本站文章系自动翻译,站长会周期检查,如果有不当内容,请点此留言,非常感谢。
  • Abhinav
  • Abigail Pain
  • Adam Fortuna
  • Alberto Gallego
  • Alex Wlchan
  • Answer.AI
  • Arne Bahlo
  • Ben Carlson
  • Ben Kuhn
  • Bert Hubert
  • Bits about Money
  • Brian Krebs
  • ByteByteGo
  • Chip Huyen
  • Chips and Cheese
  • Christopher Butler
  • Colin Percival
  • Cool Infographics
  • Dan Sinker
  • David Walsh
  • Dmitry Dolzhenko
  • Dustin Curtis
  • Elad Gil
  • Ellie Huxtable
  • Ethan Marcotte
  • Exponential View
  • FAIL Blog
  • Founder Weekly
  • Geoffrey Huntley
  • Geoffrey Litt
  • Greg Mankiw
  • Henrique Dias
  • Hypercritical
  • IEEE Spectrum
  • Investment Talk
  • Jaz
  • Jeff Geerling
  • Jonas Hietala
  • Josh Comeau
  • Lenny Rachitsky
  • Liz Danzico
  • Lou Plummer
  • Luke Wroblewski
  • Matt Baer
  • Matt Stoller
  • Matthias Endler
  • Mert Bulan
  • Mostly metrics
  • News Letter
  • NextDraft
  • Non_Interactive
  • Not Boring
  • One Useful Thing
  • Phil Eaton
  • Product Market Fit
  • Readwise
  • ReedyBear
  • Robert Heaton
  • Ruben Schade
  • Sage Economics
  • Sam Altman
  • Sam Rose
  • selfh.st
  • Shtetl-Optimized
  • Simon schreibt
  • Slashdot
  • Small Good Things
  • Taylor Troesh
  • Telegram Blog
  • The Macro Compass
  • The Pomp Letter
  • thesephist
  • Thinking Deep & Wide
  • Tim Kellogg
  • Understanding AI
  • 英文媒体
  • 英文推特
  • 英文独立博客
©2025 搞英语 → 看世界 | Design: Newspaperly WordPress Theme