euler87.c: Funktionen mit static definieren
Beim Kompilieren mit clang -Weverything hat sich gezeigt, dass der Compiler eigentlich gern eine Deklaration der Funktionen zuvor hätte. Um dem Compiler zu sagen, dass diese Funktionen nur innerhalb dieser Compilie-Unit benötigt werden und daher keine Deklaration zuvor notwendig ist, müssen die Funktionen mit static versehen werden.
This commit is contained in:
parent
4013507f58
commit
c4c0ebfb4d
2 changed files with 6 additions and 5 deletions
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
CFLAGS=-g -O2 -fPIC -fPIE -Wall -Wextra -Wformat=2 -Wunused -Wlogical-op -Wundef \
|
CFLAGS=-g -O2 -fPIC -fPIE -Wall -Wextra -Wformat=2 -Wunused -Wlogical-op -Wundef \
|
||||||
-Wswitch-enum -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings \
|
-Wswitch-enum -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings \
|
||||||
-Wconversion -D_FORTIFY_SOURCE=2 -fstack-protector -Wshadow -Wnested-externs
|
-Wconversion -D_FORTIFY_SOURCE=2 -fstack-protector -Wshadow -Wnested-externs \
|
||||||
|
-Wmissing-prototypes
|
||||||
|
|
||||||
LDFLAGS=-lm
|
LDFLAGS=-lm
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int gen_prime_numbers(uint limit, uint* pn, uint** pn_end)
|
static int gen_prime_numbers(uint limit, uint* pn, uint** pn_end)
|
||||||
{
|
{
|
||||||
pn[0] = 2u;
|
pn[0] = 2u;
|
||||||
pn[1] = 3u;
|
pn[1] = 3u;
|
||||||
|
@ -43,14 +43,14 @@ typedef struct {
|
||||||
uint* mem_end;
|
uint* mem_end;
|
||||||
} vector_uint;
|
} vector_uint;
|
||||||
|
|
||||||
void vector_init(vector_uint* vec)
|
static void vector_init(vector_uint* vec)
|
||||||
{
|
{
|
||||||
vec->begin = NULL;
|
vec->begin = NULL;
|
||||||
vec->end = NULL;
|
vec->end = NULL;
|
||||||
vec->mem_end = NULL;
|
vec->mem_end = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmp_uint(const void* p1, const void* p2)
|
static int cmp_uint(const void* p1, const void* p2)
|
||||||
{
|
{
|
||||||
const uint a = *(const uint*)p1;
|
const uint a = *(const uint*)p1;
|
||||||
const uint b = *(const uint*)p2;
|
const uint b = *(const uint*)p2;
|
||||||
|
@ -61,7 +61,7 @@ int cmp_uint(const void* p1, const void* p2)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vector_add(vector_uint* vec, uint el)
|
static int vector_add(vector_uint* vec, uint el)
|
||||||
{
|
{
|
||||||
if (vec->end >= vec->mem_end)
|
if (vec->end >= vec->mem_end)
|
||||||
{
|
{
|
||||||
|
|
Reference in a new issue