-
-
Save kazmura11/392e52c2b1ca9f671bdd to your computer and use it in GitHub Desktop.
C言語のヘッダの書き方(a.c)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "a.h" | |
#include <stdio.h> | |
#include "Global.h" | |
// 構造体の完全な定義を書く | |
typedef struct tag_bar | |
{ | |
int a; | |
int b; | |
char c[4]; | |
} Bar; | |
// 要はprivateのようなもの | |
// この中だけで使う関数 | |
static void bar_proc_1(Bar *bar); | |
static void bar_proc_2(Bar *bar, int n); | |
// この中だけで使うグローバル変数はstaticに | |
static int g_internal; | |
void bar_proc() | |
{ | |
Bar bar = { 1, 2, "abc"}; | |
bar_proc_1(&bar); | |
bar_proc_2(&bar, 1); | |
// ... | |
g_foo = -1; | |
printf("[%s] g_foo : %d\n", __func__, g_foo); | |
g_FooBar.a = -1; | |
g_FooBar.b = -2; | |
printf("[%s] g_FooBar.a : %d, g_FooBar.b : %d\n", | |
__func__, g_FooBar.a, g_FooBar.b); | |
} | |
void bar_proc_1(Bar *bar) | |
{ | |
printf("[%s] called.\n", __func__); | |
// ... | |
} | |
void bar_proc_2(Bar *bar, int n) | |
{ | |
printf("[%s] called.\n", __func__); | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment