Huy Vũ Quang

29 bundles
3 filesa month ago
1

GCC Sample Code

function.h

12345678910
#pragma once #define FIRST_OPTION #ifdef FIRST_OPTION #define MULTIPLIER (3.0) #else #define MULTIPLIER (2.0) #endif float add_and_multiply(float x, float y);

function.c

12345678910111213141516
#include "function.h" int nCompletionStatus = 0; float add(float x, float y) { float z = x + y; return z; } float add_and_multiply(float x, float y) { float z = add(x,y); z *= MULTIPLIER; return z; }

main.c

12345678910111213
#include "function.h" extern int nCompletionStatus; int main(int argc, char* argv[]) { float x = 1.0; float y = 5.0; float z; z = add_and_multiply(x,y); nCompletionStatus = 1; return 0; }