0

只是关于 C 和编译器的一些基本问题。

我计划使用 ATLAS 库,但是我只会使用其中的两三个算法。如果我只包含一个标题,那么是否只会构建该标题并且我的 SW 不会变得太大?还是将整个 ATLAS 库都包含在内?所以也许最好只是剪切和粘贴该算法?

4

1 回答 1

0

If you use the #include directive, the entirety of that header file is literally pasted into your document. The #include is recursive though, i.e. it nests (up to 256 levels), so whatever is #included in the file you include is also included. To give an example:

yourprogram.c, lib1.h, and lib2.h

/* yourprogram.c */
#include <lib1.h>

int main(void)
{
    printf("Hello, world.");
    return 0;
}

/* lib1.h */
#include <lib2.h>

void function1(void);
void function2(void);

/* lib2.h */

void function3(void);
void function4(void);

After preprocessing

/* yourprogram.c (after preprocessing) */

void function3(void);    
void function4(void);

void function1(void);
void function2(void);

int main(void)
{
    printf("Hello, world.");
    return 0;
}
于 2014-03-17T12:27:09.810 回答