Thread: Does the C compiler compile the code line by line(or for example it jumps too)?

  1. #1
    Registered User
    Join Date
    Oct 2018
    Posts
    42

    Does the C compiler compile the code line by line(or for example it jumps too)?

    I know very little about the internals of compilers. Does the C compiler compile the code line by line(or for example it jumps too)? I read some lines in a book about the difference between an operator and a function and the author says operators are just turned into a sequence of instructions by the compiler, however, in regards to functions it has to "jump". It is strange to me since I thought jumping is something that happens in the runtime and a compiler is only reading the code line by line and is turning each line into an assembly code(even joining function declarations and definitions is postponed until the linking stage). So does the compiler jump?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    The compiler doesn't move around in the code. The sequence of instructions that is generated for a function call will have a "jump" in it, because the flow of execution will transfer to wherever that function lives (in a library, your own code, wherever) and then jump back. (Usually something like call and return.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 06-07-2012, 02:50 AM
  2. Replies: 7
    Last Post: 12-13-2010, 02:13 PM
  3. Replies: 1
    Last Post: 05-20-2006, 11:17 PM
  4. how to compile on the command line
    By majoub in forum C Programming
    Replies: 2
    Last Post: 04-23-2005, 07:40 AM
  5. Replies: 4
    Last Post: 11-14-2001, 10:28 AM

Tags for this Thread