Move type definitions before the first include

This way the last remaining uses of int could be replaced with sint32 as
well. Before this change there was a circular dependancy which made the
types unknown in diagnostic.h.
This commit is contained in:
Broxzier 2017-01-04 22:27:25 +01:00
parent 60603ae10a
commit d857ebb2ad
3 changed files with 11 additions and 9 deletions

View File

@ -37,8 +37,6 @@
#include <string.h>
#include <stdbool.h>
#include "diagnostic.h"
typedef int8_t sint8;
typedef int16_t sint16;
typedef int32_t sint32;
@ -48,6 +46,8 @@ typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
#include "diagnostic.h"
typedef char utf8;
typedef utf8* utf8string;
typedef const utf8* const_utf8string;

View File

@ -19,8 +19,8 @@
#include <stdio.h>
#include "diagnostic.h"
int _log_levels[DIAGNOSTIC_LEVEL_COUNT] = { 1, 1, 1, 0, 1 };
int _log_location_enabled = 1;
sint32 _log_levels[DIAGNOSTIC_LEVEL_COUNT] = { 1, 1, 1, 0, 1 };
sint32 _log_location_enabled = 1;
const char * _level_strings[] = {
"FATAL",
@ -30,7 +30,7 @@ const char * _level_strings[] = {
"INFO"
};
void diagnostic_log(int diagnosticLevel, const char *format, ...)
void diagnostic_log(sint32 diagnosticLevel, const char *format, ...)
{
FILE *stream;
va_list args;
@ -52,7 +52,7 @@ void diagnostic_log(int diagnosticLevel, const char *format, ...)
fprintf(stream, "\n");
}
void diagnostic_log_with_location(int diagnosticLevel, const char *file, const char *function, int line, const char *format, ...)
void diagnostic_log_with_location(sint32 diagnosticLevel, const char *file, const char *function, sint32 line, const char *format, ...)
{
FILE *stream;
va_list args;

View File

@ -48,6 +48,8 @@ enum {
* only checking whether the define is present or not.
*/
#include "common.h"
#if defined(DEBUG)
#if DEBUG > 0
#define DEBUG_LEVEL_1 1
@ -73,14 +75,14 @@ enum {
#define DEBUG_LEVEL_1 0
#endif // defined(DEBUG)
extern int _log_levels[DIAGNOSTIC_LEVEL_COUNT];
extern sint32 _log_levels[DIAGNOSTIC_LEVEL_COUNT];
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void diagnostic_log(int diagnosticLevel, const char *format, ...);
void diagnostic_log_with_location(int diagnosticLevel, const char *file, const char *function, int line, const char *format, ...);
void diagnostic_log(sint32 diagnosticLevel, const char *format, ...);
void diagnostic_log_with_location(sint32 diagnosticLevel, const char *file, const char *function, sint32 line, const char *format, ...);
#ifdef __cplusplus
}