版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013163834/article/details/85218331
main.c
#include <stdio.h>
#include "BaseStore.h"
int main()
{
baseStore_aboutSizeofFunc();
return 0;
}
BaseStore.h
#include <stdio.h>
void baseStore_aboutSizeofFunc();
BaseStore.c
#include "BaseStore.h"
void baseStore_aboutSizeofFunc()
{
int integerType;
float floatType;
double doubleType;
char charType;
// sizeof操作符用于计算变量的字节大小
printf("size of int: %d bytes\n",sizeof(integerType));
printf("size of float: %d bytes\n",sizeof(floatType));
printf("size of double: %d bytes\n",sizeof(doubleType));
printf("size of char: %d bytes\n",sizeof(charType));
return;
}
重点在于编译: 在tasks.json 文件中包含要引用的文件
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "gcc",
"args": [
"-g","main.c",
"-g","BaseStore.c"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
编译执行
E:\C_Study>gcc main.c BaseStore.c -o main
E:\C_Study>main.exe
size of int: 4 bytes
size of float: 4 bytes
size of double: 8 bytes
size of char: 1 bytes
E:\C_Study>
问题:
main.c
引入多个C文件该怎么办?求大神指导
参考链接
https://blog.csdn.net/u013145697/article/details/85112700
https://segmentfault.com/q/1010000015905887
https://blog.csdn.net/sunshine_in_moon/article/details/50396942