Fixed many incompatible pointer warnings; add tcc specific debugging flags to makefile

This commit is contained in:
John Alanbrook 2022-12-14 19:01:42 +00:00
parent 60bf5ca7bc
commit 0b64d0872b
16 changed files with 57 additions and 59 deletions

View file

@ -14,6 +14,9 @@ PTYPE != uname -m
ifeq ($(DBG), 1)
QFLAGS = -O0 -g -DDBG=1 -DED=1
ifeq ($(CC), tcc)
QFLAGS += -b -bt24
endif
INFO = dbg
endif
@ -22,7 +25,7 @@ ifeq ($(ED), 0)
INFO = ed
endif
BIN = bin/
BIN = bin/$(CC)/
objprefix = $(BIN)obj/$(INFO)
define prefix
@ -46,7 +49,7 @@ eobjects != $(call rm,$(eobjects),sqlite pl_mpeg_extract_frames pl_mpeg_player y
includeflag != $(call prefix,$(edirs),-I)
WARNING_FLAGS = #-Wall -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
WARNING_FLAGS = -Wall# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
SEM = 0.0.1
COM != git rev-parse --short HEAD
@ -54,7 +57,7 @@ VER = $(SEM)-$(COM)
COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -c $< -o $@
LIBPATH = -Lbin
LIBPATH = -L$(BIN)
ifeq ($(OS), WIN32)
LINKER_FLAGS = $(QFLAGS)
@ -89,6 +92,8 @@ DIST = yugine-$(MYTAG).tar.gz
.PHONY: yugine
yugine: $(BIN)yugine
$(BIN)yugine: $(objprefix)/source/engine/yugine.o $(ENGINE)
@echo Linking yugine
$(CC) $< $(LINK) -o $(BIN)yugine
@ -127,5 +132,5 @@ $(objprefix)/%.o:%.c
.PHONY: clean
clean:
@echo Cleaning project
@find $(BIN) -type f -delete
@rm -rf bin/*
@rm -f *.gz

View file

@ -153,7 +153,7 @@ void box_gui(struct phys2d_box *box)
{
nk_property_float(ctx, "Width", 0.f, &box->w, 1000.f, 1.f, 1.f);
nk_property_float(ctx, "Height", 0.f, &box->h, 1000.f, 1.f, 1.f);
nk_property_float2(ctx, "Offset", 0.f, &box->offset, 1.f, 0.01f, 0.01f);
nk_property_float2(ctx, "Offset", 0.f, box->offset, 1.f, 0.01f, 0.01f);
phys2d_applybox(box);
}

View file

@ -76,19 +76,3 @@ Serialize *make_staticactor()
*/
#include "nuke.h"
void staticactor_gui(struct mStaticActor *sa)
{
object_gui(&sa->obj);
if (nk_tree_push(ctx, NK_TREE_NODE, "Model", NK_MINIMIZED)) {
nk_checkbox_label(ctx, "Cast Shadows", &sa->castShadows);
nk_labelf(ctx, NK_TEXT_LEFT, "Model path: %s", sa->currentModelPath);
//ImGui::SameLine();
if (nk_button_label(ctx, "Load model")) {
//asset_command = set_new_model;
curActor = sa;
}
}
}

View file

@ -55,7 +55,7 @@ void draw_line(int x1, int y1, int x2, int y2)
x2, y2
};
draw_poly(&verts, 2);
draw_poly(verts, 2);
}
void draw_edge(float *points, int n)
@ -98,7 +98,7 @@ void draw_rect(int x, int y, int w, int h)
x - hw, y + hh
};
draw_poly(&verts, 4);
draw_poly(verts, 4);
}
void draw_grid(int width, int span)

View file

@ -5,6 +5,7 @@
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#define logLevel 0
@ -12,7 +13,7 @@
char *logstr[] = { "INFO", "WARN", "ERROR", "CRITICAL" };
char *catstr[] = {"ENGINE"};
FILE *fout = NULL;
void mYughLog(int category, int priority, int line, const char *file, const char *message, ...)
{
@ -30,19 +31,15 @@ void mYughLog(int category, int priority, int line, const char *file, const char
char buffer[ERROR_BUFFER] = { '\0' };
snprintf(buffer, ERROR_BUFFER, "%s | %s | %s [ %s:%d ] %s\n", logstr[priority], catstr[0], dt, file, line, msgbuffer);
printf("%s", buffer);
fprintf(stderr, "%s", buffer);
fprintf(stdout, "%s", buffer);
fflush(stdout);
if (fout) {
fprintf(fout, "%s", buffer);
fflush(fout);
}
}
}
void log_setfile(char *file) {
YughInfo("Opening output log %s.", file);
fout = fopen(file, "w");
freopen(file, "w", stderr);
}
void log_cat(FILE *f) {

View file

@ -1,5 +1,8 @@
#include "ed_project.h"
#include <string.h>
#include <stdlib.h>
#include <vec.h>
#include "editor.h"
void editor_init_project(struct gameproject *gp)
@ -17,8 +20,7 @@ void editor_init_project(struct gameproject *gp)
void editor_make_project(char *path)
{
FILE *f = path_open("w", "%s%s", path, "/project.yugh");
cur_project =
(struct gameproject *) malloc(sizeof(struct gameproject));
cur_project = malloc(sizeof(struct gameproject));
strncpy(cur_project->name, "New Game", 127);
strncpy(cur_project->path, path, 2048);
vec_add(projects, cur_project);
@ -36,7 +38,7 @@ void editor_import_project(char *path)
if (!f)
return;
struct gameproject *gp = (struct gameproject *) malloc(sizeof(*gp));
struct gameproject *gp = malloc(sizeof(*gp));
fread(gp, sizeof(*gp), 1, f);
fclose(f);

View file

@ -27,6 +27,7 @@
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include "nuke.h"
#include "log.h"
@ -48,9 +49,9 @@ static bool renderAO = true;
static bool renderDynamicShadows = true;
// Debug render modes
static bool renderGizmos = false;
static bool showGrid = true;
static bool debugDrawPhysics = false;
static int renderGizmos = false;
static int showGrid = true;
static int debugDrawPhysics = false;
const char *allowed_extensions[] = {"jpg", "png", "rb", "wav", "mp3", };
@ -81,8 +82,8 @@ static int grid1_width = 1;
static int grid1_span = 100;
static int grid2_width = 3;
static int grid2_span = 1000;
static bool grid1_draw = true;
static bool grid2_draw = true;
static int grid1_draw = true;
static int grid2_draw = true;
static float tex_scale = 1.f;
static struct TexAnimation tex_gui_anim = {0};
@ -495,7 +496,7 @@ void editor_project_gui() {
*/
NK_MENU_START(level)
nuke_nel(1);
nuke_labelf(ctx, "Current level: %s", current_level[0] == '\0' ? "No level loaded." : current_level);
nuke_labelf("Current level: %s", current_level[0] == '\0' ? "No level loaded." : current_level);
nuke_nel(3);
if (nk_button_label(ctx, "New")) {
@ -585,9 +586,9 @@ void editor_project_gui() {
NK_MENU_START(debug)
if (nk_tree_push(ctx, NK_TREE_NODE, "Debug Draws", NK_MINIMIZED)) {
nk_checkbox_label(ctx, "Gizmos", &renderGizmos);
nk_checkbox_label(ctx, "Grid", &showGrid);
nk_checkbox_label(ctx, "Physics", &debugDrawPhysics);
nuke_checkbox("Gizmos", &renderGizmos);
nuke_checkbox("Grid", &showGrid);
nuke_checkbox("Physics", &debugDrawPhysics);
nk_tree_pop(ctx);
}
@ -596,7 +597,7 @@ void editor_project_gui() {
NK_MENU_START(hierarchy)
nk_layout_row_dynamic(ctx, 25, 1);
if (nk_button_label(ctx, "New Object")) {
if (nuke_btn("New Object")) {
MakeGameobject();
}

View file

@ -79,7 +79,7 @@ struct sFont *MakeFont(const char *fontfile, int height)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
for (unsigned char c = 32; c < 128; c++) {
for (unsigned char c = 32; c < 127; c++) {
unsigned char *bitmap;
int advance, lsb, w, h, x0, y0;
stbtt_GetCodepointHMetrics(&fontinfo, c, &advance, &lsb);

View file

@ -17,7 +17,7 @@ struct Character {
struct sFont {
uint32_t fontTexture;
uint32_t height;
struct Character Characters[127];
struct Character Characters[126];
};

View file

@ -259,9 +259,9 @@ void object_gui(struct gameobject *go)
nk_property_float(ctx, "Scale", 0.f, &go->scale, 1000.f, 0.01f, go->scale * 0.01f);
nk_layout_row_dynamic(ctx, 25, 3);
nk_radio_button_label(ctx, "Static", &go->bodytype, CP_BODY_TYPE_STATIC);
nk_radio_button_label(ctx, "Dynamic", &go->bodytype, CP_BODY_TYPE_DYNAMIC);
nk_radio_button_label(ctx, "Kinematic", &go->bodytype, CP_BODY_TYPE_KINEMATIC);
nuke_radio_btn("Static", &go->bodytype, CP_BODY_TYPE_STATIC);
nuke_radio_btn("Dynamic", &go->bodytype, CP_BODY_TYPE_DYNAMIC);
nuke_radio_btn("Kinematic", &go->bodytype, CP_BODY_TYPE_KINEMATIC);
cpBodySetType(go->body, go->bodytype);

View file

@ -1,5 +1,7 @@
#include "input.h"
#include <stdio.h>
#include "script.h"
#include "stb_ds.h"
int32_t mouseWheelX = 0;
@ -57,7 +59,7 @@ void input_poll(double wait)
//editor_input(&e);
for (int i = 0; i < arrlen(downkeys); i++)
call_input_down(downkeys[i]);
call_input_down(&downkeys[i]);
}
void win_key_callback(GLFWwindow *w, int key, int scancode, int action, int mods)

View file

@ -104,13 +104,6 @@ void wav_norm_gain(struct wav *w, double lv)
}
}
struct osc sin600;
struct osc sin20;
struct dsp_ammod dspammod;
struct dsp_delay dspdel;
struct wav s600wav;
struct sound s600wavsound;
void sound_init()
{
PaError err = Pa_Initialize();

View file

@ -153,4 +153,6 @@ void dsp_mono(void *p, short *out, int n);
void dsp_bitcrush(void *p, short *out, int n);
void dsp_run(struct dsp_filter filter, short *out, int n);
#endif

View file

@ -2,6 +2,8 @@
#include "stddef.h"
#include "time.h"
#include "sound.h"
#include "dsp.h"
#include <string.h>
static struct bus bus[256];
short mastermix[BUF_FRAMES*CHANNELS];

View file

@ -8,6 +8,8 @@
#include "script.h"
#include "nuke.h"
#include "openglrender.h"
#include "stb_ds.h"
struct window *mainwin;
@ -21,7 +23,7 @@ int is_win(struct window *s, GLFWwindow *w)
return s->window == w;
}
void window_size_callback(GLFWwindow *w)
void window_size_callback(GLFWwindow *w, int width, int height)
{
}

View file

@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef __linux__
#include <execinfo.h>
#endif
@ -83,6 +84,13 @@ int main(int argc, char **args) {
exit(1);
break;
case 'h':
printf("-l Set log file\n");
printf("-play Launch engine in play mode instead of editor mode\n");
printf("-v Display engine info\n");
exit(0);
break;
}
}
}