What Is the C Language? Is It Open Source?

 ・ 3 min

photo by Steve Johnson(https://unsplash.com/@steve_j?utm_source=templater_proxy&utm_medium=referral) on Unsplash

While at the 42Seoul Gaepo cluster, I suddenly wondered: we call so many projects like Linux, Dart, and Flutter "open source," so is C also open source?

After looking into it, I found that C isn't software. So rather than being open source, it's a defined standard. Various compilers were developed to concretely implement and comply with this defined standard, which led to many open source C compilers. Examples: GCC, MSVC

C was just a "standard" for a language. It's not something anyone can own -- it's a language everyone can use. Anyone could develop compilers or interpreters using this standard. However, creating a language wouldn't have been easy for people unfamiliar with computers or for small teams.

What Is the C Language?#

image

C is written in .c file format following rules that programs must adhere to in order to execute. The written source code can only be understood by humans -- computers can't directly understand it. A process is needed to convert source code into machine language so that computers can understand it, and a tool called a compiler is essential in this process.

During the compilation process, the source code is checked for syntax errors and converted into a state that can be executed on a computer.

  • The preprocessor performs code preprocessing
  • The compiler converts the preprocessed file into machine language, generating object files
  • The linker combines object files with necessary startup code and other components to produce the final executable

Why are there so many different C compilers?
Since C is used on various operating systems and hardware, compilers optimized for each environment were needed.
Different compilers were developed to meet various requirements, performance needs, and features. Open source compilers were freely modified and distributed by the community, leading to various versions tailored to specific features or environments.

Compilation Process#

The compilation process consists of several stages. You can examine each stage using the gcc command.

  1. Preprocessing: gcc -E main.c -o main.i
    The preprocessor interprets preprocessing directives like #include and #define, processing external files and macros needed in the code to generate a preprocessed file
  2. Compilation: gcc -S main.i -o main.s
    The preprocessed file is converted into assembly language. Assembly language is an intermediate form of code converted to run on specific hardware
  3. Assembly: gcc -c main.s -o main.o
    Converts assembly code into machine language to generate object files (.o)
  4. Linking: gcc main.o -o main.exe
    The linker combines object files with startup code and other components to create the executable. Startup code performs necessary preparation tasks before program execution and is responsible for calling the main() function.

Where focus goes, energy flows.

— Tony Robbins


Other posts
Exploring the Record Input Fields in Route 53 커버 이미지
 ・ 5 min

Exploring the Record Input Fields in Route 53

Useful Links for Flutter Developers 커버 이미지
 ・ 2 min

Useful Links for Flutter Developers

Why Peer Learning Matters feat. 42 Seoul 커버 이미지
 ・ 4 min

Why Peer Learning Matters feat. 42 Seoul