Search code examples
gccarchitecturecompiler-constructioncpu-architecture

what is target architecture in computer science?


I am a beginner in programming and wanted to download a good C compiler to practice coding. So I thought of GCC and started a small research on it. I read a Wikipedia article on it. The article mentioned something about target architecture,which I do not know. Can anyone tell me what it means, and any source I can refer for more information. Thanks in advance.


Solution

  • The target architecture is the architecture which the compiler creates binary files for.

    Common architectures are: i386 (Intel 32-bit), x86_64 (Intel 64-bit), armv7, arm64, etc...

    GCC compiles C code (after the preprocessing stage) to assembly code, and the assembly code varies depending on the CPU architecture. The assembly code is then "assembled" to a binary file.

    Something to keep in mind:

    Two binary files are not guaranteed to be compatible across different operating systems despite sharing the same architecture.

    A program compiled on Ubuntu Linux (let's say with arch x86_64) won't work on Windows (with same arc x86_64).

    GCC identifies architectures by "triplets", like:

    x86_64-apple-darwin14.0.0
    i386-pc-mingw32
    i686-pc-linux-gnu
    

    Format is:

    machine-vendor-operatingsystem (not always followed though)
    

    They contain infos on both the architecture and the operating system.