I want to execuate own file to test the “struct” in TH, like THStorage.
Copy the file from github. I am confusing about, how to make link of the storage file in the generic, I always get the error of “the function not define: like THLongStorage_new”，（I can achieve only one type, but i always get error when to achieve the “templates” in C）.
My CMakeLists.txt as follows:
cmake_minimum_required(VERSION 3.7)
project(MyProj)
set(CMAKE_C_STANDARD 99)
INCLUDE(CheckCSourceRuns)
CHECK_C_SOURCE_RUNS(“
int main()
{
int a;
__sync_lock_test_and_set(&a, 1);
__sync_fetch_and_add(&a, 1);
if(!__sync_bool_compare_and_swap(&a, 2, 3))
return -1;
return 0;
}
” HAS_GCC_ATOMICS)
IF (HAS_MSC_ATOMICS)
ADD_DEFINITIONS(-DUSE_MSC_ATOMICS=1)
MESSAGE(STATUS “Atomics: using MSVC intrinsics”)
ELSEIF (HAS_GCC_ATOMICS)
ADD_DEFINITIONS(-DUSE_GCC_ATOMICS=1)
MESSAGE(STATUS “Atomics: using GCC intrinsics”)
ELSE ()
SET(CMAKE_THREAD_PREFER_PTHREAD TRUE)
FIND_PACKAGE(Threads)
IF (THREADS_FOUND)
ADD_DEFINITIONS(-DUSE_PTHREAD_ATOMICS=1)
TARGET_LINK_LIBRARIES(TH ${CMAKE_THREAD_LIBS_INIT})
MESSAGE(STATUS “Atomics: using pthread”)
ENDIF ()
ENDIF ()
set(hdr THGeneral.h THAtomic.h THGenerateAllTypes.h THGenerateByteType.h THGenerateCharType.h
THGenerateDoubleType.h THGenerateFloatType.h THGenerateFloatTypes.h THGenerateHalfType.h
THGenerateIntType.h THGenerateLongType.h THGenerateShortType.h THGenerateIntTypes.h THHalf.h
THAllocator.h THStorage.h TH.h generic/THStorage.c)
set(src main.c THGeneral.c THAtomic.c THHalf.c THAllocator.c generic/THStorage.c)
set(SOURCE_FILES ${src} ${hdr})
add_subdirectory(generic)
add_executable(MyProj ${SOURCE_FILES})
target_link_libraries(MyProj m)ext by 4 spaces