[solved] "templates" about TH file

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

In every “type”, using follow two lines:
#line 1 TH_GENERIC_FILE
#include TH_GENERIC_FILE

But It seems not include (It must something I dont see).

Thank you advance !

A similar question:
temp1.h
#ifndef NEW_TEMP
#define NEW_TEMP “temp1.h”
#else
#define A 1
int add(int a, int b);
#endif

temp1.c
#ifndef NEW_TEMP
#define NEW_TEMP “temp1.c”
#else
int add(int a, int b)
{
return a+b;
}
#endif

temp2.h
#ifndef NEW_TEMP
#error “You must define TH_GENERIC_FILE before including THGenerateLongType.h”
#endif
#line 1 NEW_TEMP
#include NEW_TEMP

main.c
#include “stdio.h”
#include “temp1.h”
#include “temp2.h"
int main()
{
printf(”%d\n", A);
int a = 10, b=2;
int c = add(a, b);
printf(“wait”);
}

there is error as well. How to build the link of temp1.h and temp1.c ? (if we delete the temp1.c, and write code in the “temp1.h”, there is no error )

Oh no! it’s so stupid of myself!.. I find it in the TH/THStorage.c, there #include the .c file.