C, C++7 CMake에서 외부 패키지 가져오기 https://cmake.org/cmake/help/latest/module/FetchContent.html#id5 FetchContent — CMake 4.3.1 DocumentationContents This module provides commands to populate content at configure time or as part of the calling script. Load this module in CMake with: Note The Using Dependencies Guide provides a high-level introduction to this general topic. It provides a broadercmake.org FetchContent를 통해, vcpkg나 co.. 2026. 4. 5. C/C++] gcc 최적화 옵션 https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html Optimize Options (Using the GNU Compiler Collection (GCC))Allow the built-in functions ceil, floor, round and trunc, and their float and long double variants, to generate code that raises the “inexact” floating-point exception for noninteger arguments. ISO C99 and C11 allow these functions to raise the “inegcc.gnu.org모든 최적화 플래그에 대해 다루지는 않으.. 2026. 3. 18. C/C++] always_inline gcc에서 __attribute__((always_inline))을 작성하여, 컴파일러에게 인라인 함수를 권고하는 대신 강제하도록 할 수 있다. https://slowcloud.tistory.com/34 템플릿 메타 프로그래밍템플릿으로 typename을 활용하여 제네릭처럼 활용하는 경우가 많지만, 일반적인 자료형을 활용하여 메타프로그래밍을 진행할 수 있다. template int factorial() { if constexpr(n () * n; }}위와 같이 단순히 상slowcloud.tistory.com상단의 글에서 작성한 코드를 그대로 활용하되, inline을 강제하도록 작성했다.우측 어셈블리 코드를 보면, 재귀호출을 하는 대신 한 함수 안에 기능이 모두 구현되어 있는 것을 확인할 수 있다. 2026. 3. 6. C++] 템플릿 메타 프로그래밍 템플릿으로 typename을 활용하여 제네릭처럼 활용하는 경우가 많지만, 일반적인 자료형을 활용하여 메타프로그래밍을 진행할 수 있다. template int factorial() { if constexpr(n () * n; }}위와 같이 단순히 상수를 넘겨받는 식으로 템플릿을 작성할 수 있으며, 재귀적으로 템플릿 함수를 호출하여 코드를 생성할 수 있다. 위는 코드를 컴파일했을 때 생성된 어셈블리 코드를 보여주는 사이트이다.상단의 코드를 좌측과 같이 작성했을 때, 우측의 어셈블리 코드에서 10 이하에 대한 팩토리얼 코드가 작성되는 것을 확인할 수 있다. 템플릿을 활용하면 컴파일 타임에 연산을 수행하여 더 빠르게 작동하는 프로그램을 작성할 수 있다. 상단은 컴파일 최적화 옵션을 넣고 컴파일한 결과.. 2026. 3. 6. C] spinlock https://man7.org/linux/man-pages/man3/pthread_spin_init.3.html pthread_spin_init(3) - Linux manual page man7.org 대기 시간이 짧을 경우, mutex보다 spinlock이 훨씬 빠르게 작업을 처리한다.#include #include #define endl "\n"#define THREAD_COUNT 1000int value = 0;pthread_spinlock_t spinlock;void *f(void *data) { size_t idx = (size_t)data; for (int i = 0; i 스핀락의 경우, 초기화 시 락을 프로세스 단위로 공유할 것인지에 대한 여부를 설정해주어야 한다.프로세스 간 공유가 .. 2026. 3. 5. C] pthread_mutex_t 활용하기 https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread.h.html" data-og-description="The header defines the following symbols: PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DISABLE PTHREAD_CANCELED PTHREAD_COND_INITIALIZER PTHREAD_CREATE_DETACHED PTHREAD_CREATE_JOINABLE PTHREAD_EXPLICIT_SCHED PTHR" data-og-host="pubs.opengroup.org" data-og-source-url=.. 2026. 3. 4. 이전 1 2 다음