English 中文(简体)
C自食堂本身如何?
原标题:How do C self-hosts itself?

Anyone knows the complete chain of operations from .c source code to finally an executable .exe?

I ve 下载了gcc的源头,发现其c-parser.y也在c中写成:

extdef:
    fndef
    | datadef
    | ASM_KEYWORD  (  expr  )   ; 
        { STRIP_NOPS ($3);
          if ((TREE_CODE ($3) == ADDR_EXPR
               && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
              || TREE_CODE ($3) == STRING_CST)
            assemble_asm ($3);
          else
            error ("argument of `asm  is not a constant string"); }
    | extension extdef
        { pedantic = $<itype>1; }
    ;

因此,任何人都知道这种自毁的故事?

<>>>>>

我知道一些文字汇编者是如何撰写的,其中大多数依靠汇编者。

因此,现在我问,编辑如何工作。

最佳回答

海湾合作委员会有一个多阶段进程,但首先是一个行之有效的C汇编者(可能是或可能是另一个海合会版本)。

  1. Use the other C compiler to create a first version of GCC - the GNU C Compiler.
    • This gives you a working copy of the new version of GCC (assuming the old compiler was serviceable).
    • It is not, however, identical the compiler that (the new version of) GCC would produce, except by implausible accident.
  2. Use the first version of GCC to create a second version of GCC.
    • The second version of GCC is the (obviously) the code that GCC would generate. This is the benchmark version.
    • However, it has not yet been shown that this is stable.
  3. Use the second version of GCC to create a third version of GCC.
    • The second version of GCC should produce the same output for the third version of GCC.
  4. Ensure that the second and third versions of GCC are the same.
    • On some platforms, the object files contain compilation times; clearly, the compilation time has to discount differences in compilation time.
    • Assuming that the second and third versions are the same , then we know that GCC can produce itself from its own source code.
    • It is now safe to use the new version of GCC to build the various runtime libraries, and the other compilers in the family.
  5. Build the other parts of the GNU Compiler Collection with the new C compiler.
    • Most people do not restrict the GNU Compiler Collection to just the C compiler.
    • Typically, they also produce the C++ and Java (and usually Objective C) compilers too.
    • And you need the Standard C++ Library support too.
    • Usually, the C compiler uses the C library provide by the platform.
问题回答

你们感到惊讶的是,C汇编者是在C撰写的? 一位专家在撰写汇编者时会使用什么其他语言?

很显然的鸡蛋问题仅在很久以前就发生过一次,当时完全有no汇编器。 之后,有人不得不在组装上写一个字(在有人在机器编码中写了第一个组装机:-)





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签