Makefile工程管理
demo文件如下:
sequence.h
#ifndef _SEQUENCE_H_
#define _SEQUENCE_H_
void sequence(unsigned char*sp,unsigned char num);
#endif
sequence.c
#include "sequence.h"void sequence(unsigned char *sp,unsigned char num)
{
unsigned char i,j;
unsigned char a;
for(j=0;j<num-1;i++)
{
for(i=j+1;i<num;i++)
{
if(sp[j]>sp[i])
{
a=sp[i];
sp[i]=sp[j];
sp[j]=a;
}
}
}
}
main.c
#include <stdio.h>
#include "sequence.h"
unsigned char dis_num[8] = {10,9,17,92,2,8,35,12};
int main(void)
{
unsigned char i;
sequence(dis_num,sizeof(dis_num));
for(i=0;i<8;i++)printf("%d ",dis_num[i]);
printf("\r\n");
return 0;
}
处理如下:
gcc -o sequence.o -c sequence.c
gcc -o main.o -c main.c
gcc -o main sequence.o main.o
./main
原文:https://www.cnblogs.com/little-kwy/p/12293397.html