본문 바로가기

Embedded4

[Embedded] Unittest using GoogleTest on CMake In this posting, we will learn how to run a unittest for C. We will use GoogleTest and CMake for this. Prerequisite CMake Please refer to this post. 2021.10.13 - [Embedded] - [C] Build using CMake GoogleTest Clone the googletest into your project. $ git clone https://github.com/google/googletest/ Prepare Project This is the project tree. +-- src +-- main.c +-- calc.h +-- calc.c +-- googletest +-.. 2021. 10. 13.
[Embedded] Build using CMake CMake is an open-source, cross-platform build tool. In this posting, we will use CMake to build a C project. Prerequisite CMake You can install the latest CMake on this page. https://cmake.org/download/ I installed it with Homebrew. $ brew install cmake VSCode Extensions If you are using VSCode, you can install these extensions. It will help you a lot. Single File Project Let's create a project... 2021. 10. 13.
[C] Preprocessors - #if, #ifdef, #if defined In this posting, we will take a look at the differences among #if, #ifdef, and #if defined. #if #if directive only works with a true or false value. #define TEST1 #if TEST #error "This would be an error as well." #endif It can be used with an expression. #define TEST0 #if (TEST == 0) #error "This would be an error as well." #endif It is also able to extend with #elif and #else. #define TEST2 #if.. 2021. 6. 11.
[C] Get return address of functions (__builtin_return_address) Let's get the return address of a function with __builtin_return_address. Syntax void* __builtin_return_address(unsigned int level); level 0 : Return the address of the current function 1 : Return the address of the caller of the current function 2 ~ 63 : Return the address of the caller's caller, and so forth If the top of the call stack has been reached, the function will return 0. It is usual.. 2021. 3. 2.