This commit is contained in:
2026-05-02 15:32:18 +08:00
commit fa9b069697
6 changed files with 50 additions and 0 deletions

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
# Xmake cache
.xmake/
build/
.vscode/
# MacOS Cache
.DS_Store

4
include/add.h Normal file
View File

@@ -0,0 +1,4 @@
#ifndef ADD_H
#define ADD_H
int add(int a, int b);
#endif

4
src/a001.c Normal file
View File

@@ -0,0 +1,4 @@
#include <stdio.h>
int main() {
printf("hello world");
}

12
src/a002.c Normal file
View File

@@ -0,0 +1,12 @@
#include "stdio.h"
int main() {
int a,b;
a = 10;b = 20;
short c = 10;
int alen = sizeof a;
int clen = sizeof(c);
short longlen = sizeof(long);
long long lllen = sizeof(long long);
printf("内存大小(字节):\na(int)=%d B\nc(short)=%hd B\nlong: %d B\n",alen,clen,longlen);
printf("longlong: %lld B",lllen);
}

4
src/add.c Normal file
View File

@@ -0,0 +1,4 @@
#include "add.h"
int add(int a,int b) {
return a + b ;
}

17
xmake.lua Normal file
View File

@@ -0,0 +1,17 @@
target("a001")
set_kind("binary")
add_files("src/a001.c")
target("a002")
set_kind("binary")
add_files("src/a002.c")
target("add0")
set_kind("static")
add_files("src/add.c")
add_includedirs("include")
target("add1")
set_kind("shared")
add_files("src/add.c")
add_includedirs("include")