mirror of
https://gitee.com/apaki/cmake_demo.git
synced 2025-05-17 20:01:36 +08:00
C语言实现面向对象
This commit is contained in:
parent
aec03ca7f1
commit
5f54a63d78
39
main.c
39
main.c
@ -3,46 +3,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "list.h"
|
||||
#include "config.h"
|
||||
|
||||
void list_demo(void)
|
||||
{
|
||||
struct list_t list;
|
||||
list_init(&list);
|
||||
for(uint32_t i = 0; i < 10; ++i)
|
||||
{
|
||||
list_add(&list, i);
|
||||
}
|
||||
list_print(&list);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("----- Version = %s -----\n", VERSION);
|
||||
|
||||
if(argc != 1)
|
||||
{
|
||||
printf("# Program = [%s]\n", argv[0]);
|
||||
for(uint32_t i = 1; i < argc; i++)
|
||||
{
|
||||
printf("# Param[%d] = %s\n", i ,argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_DEMO
|
||||
printf("list test!\n");
|
||||
struct list_t list;
|
||||
list_init(&list);
|
||||
|
||||
list_add(&list, 1);
|
||||
list_add(&list, 2);
|
||||
list_add(&list, 3);
|
||||
list_add(&list, 4);
|
||||
|
||||
list_print(&list);
|
||||
#else
|
||||
printf("list demo!\n");
|
||||
list_demo();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
48
test/test_list.c
Normal file
48
test/test_list.c
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "list.h"
|
||||
#include "config.h"
|
||||
|
||||
void list_demo(void)
|
||||
{
|
||||
struct list_t list;
|
||||
list_init(&list);
|
||||
for(uint32_t i = 0; i < 10; ++i)
|
||||
{
|
||||
list_add(&list, i);
|
||||
}
|
||||
list_print(&list);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("----- Version = %s -----\n", VERSION);
|
||||
|
||||
if(argc != 1)
|
||||
{
|
||||
printf("# Program = [%s]\n", argv[0]);
|
||||
for(uint32_t i = 1; i < argc; i++)
|
||||
{
|
||||
printf("# Param[%d] = %s\n", i ,argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_DEMO
|
||||
printf("list test!\n");
|
||||
struct list_t list;
|
||||
list_init(&list);
|
||||
|
||||
list_add(&list, 1);
|
||||
list_add(&list, 2);
|
||||
list_add(&list, 3);
|
||||
list_add(&list, 4);
|
||||
|
||||
list_print(&list);
|
||||
#else
|
||||
printf("list demo!\n");
|
||||
list_demo();
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user