Switched from GNU C99 to Standard C11. Enabled pedantic warnings.
Fixed all warnings and compile errors. Confirmed successful compilation without warnings for linux (gcc, clang), windows (gcc-mingw), osx (clang-osxcross).
This commit is contained in:
parent
e4bcf929f9
commit
397719a2a2
12 changed files with 35 additions and 21 deletions
|
@ -84,7 +84,7 @@ if(WIN32)
|
|||
set(SRCs ${SRCs} taisei_err.c)
|
||||
endif()
|
||||
|
||||
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}" -Wall -Wno-parentheses -std=gnu99)
|
||||
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}" -Wall -Wno-parentheses -std=c11 -pedantic)
|
||||
|
||||
if(RELATIVE)
|
||||
add_definitions(-DRELATIVE)
|
||||
|
|
|
@ -17,7 +17,8 @@ void add_ending_entry(Ending *e, int dur, char *msg, char *tex) {
|
|||
|
||||
entry->time = e->duration;
|
||||
e->duration += dur;
|
||||
entry->msg = strdup(msg);
|
||||
entry->msg = NULL;
|
||||
stralloc(&entry->msg, msg);
|
||||
|
||||
if(tex)
|
||||
entry->tex = get_tex(tex);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "enemy.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "global.h"
|
||||
#include "projectile.h"
|
||||
#include "list.h"
|
||||
|
|
|
@ -271,8 +271,13 @@ void difficulty_color(Color *c, Difficulty diff) {
|
|||
void stralloc(char **dest, const char *src) {
|
||||
if(*dest)
|
||||
free(*dest);
|
||||
*dest = malloc(strlen(src)+1);
|
||||
strcpy(*dest, src);
|
||||
|
||||
if(src) {
|
||||
*dest = malloc(strlen(src)+1);
|
||||
strcpy(*dest, src);
|
||||
} else {
|
||||
*dest = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Inputdevice-agnostic method of checking whether a game control is pressed.
|
||||
|
|
11
src/global.h
11
src/global.h
|
@ -11,6 +11,7 @@
|
|||
#include <SDL.h>
|
||||
#include <SDL_platform.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "tscomplex.h"
|
||||
|
||||
|
@ -183,3 +184,13 @@ enum {
|
|||
#define strncpy DO_NOT_USE_strncpy_USE_strlcpy
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// These definitions are common but non-standard, so we provide our own
|
||||
//
|
||||
|
||||
#undef M_PI
|
||||
#undef M_PI_2
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
||||
#include "matrix.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "matrix.h"
|
||||
|
||||
Matrix _identity = {
|
||||
{1, 0, 0, 0},
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "projectile.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "global.h"
|
||||
#include "list.h"
|
||||
#include "vbo.h"
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "global.h"
|
||||
|
|
|
@ -107,7 +107,8 @@ void load_bgm_descriptions(const char *path) {
|
|||
*(rem++)='\0';
|
||||
Bgm_desc *desc = create_element((void **)&resources.bgm_descriptions, sizeof(Bgm_desc));
|
||||
|
||||
desc->name = strdup(line);
|
||||
desc->name = NULL;
|
||||
stralloc(&desc->name, line);
|
||||
desc->value = malloc(strlen(rem) + 6);
|
||||
if (!desc->name || !desc->value)
|
||||
{
|
||||
|
@ -142,7 +143,7 @@ void start_bgm(char *name) {
|
|||
if (!current_bgm.name || strcmp(name, current_bgm.name))
|
||||
{
|
||||
Mix_HaltMusic();
|
||||
|
||||
|
||||
current_bgm.name = realloc(current_bgm.name, strlen(name) + 1);
|
||||
if(current_bgm.name == NULL)
|
||||
errx(-1,"start_bgm():\n!- realloc error with music '%s'", name);
|
||||
|
@ -159,7 +160,7 @@ void start_bgm(char *name) {
|
|||
|
||||
if(Mix_PausedMusic()) Mix_ResumeMusic(); // Unpause music if paused
|
||||
if(Mix_PlayingMusic()) return; // Do nothing if music already playing (or was just unpaused)
|
||||
|
||||
|
||||
if(Mix_PlayMusic(current_bgm.data->music, -1) == -1) // Start playing otherwise
|
||||
printf("Failed starting BGM %s: %s.\n", current_bgm.name, Mix_GetError());
|
||||
// Support drawing BGM title in game loop (only when music changed!)
|
||||
|
@ -173,7 +174,7 @@ void start_bgm(char *name) {
|
|||
{
|
||||
current_bgm.started_at = -1;
|
||||
}
|
||||
|
||||
|
||||
printf("Started %s\n", (current_bgm.title ? current_bgm.title : current_bgm.name));
|
||||
}
|
||||
|
||||
|
@ -198,15 +199,14 @@ void stop_bgm(void) {
|
|||
|
||||
void save_bgm(void)
|
||||
{
|
||||
free(saved_bgm); // Deal with consequent saves without restore.
|
||||
saved_bgm = current_bgm.name ? strdup(current_bgm.name) : NULL;
|
||||
// Deal with consequent saves without restore.
|
||||
stralloc(&saved_bgm, current_bgm.name);
|
||||
}
|
||||
|
||||
void restore_bgm(void)
|
||||
{
|
||||
start_bgm(saved_bgm);
|
||||
free(saved_bgm);
|
||||
saved_bgm = NULL;
|
||||
stralloc(&saved_bgm, NULL);
|
||||
}
|
||||
|
||||
void set_bgm_volume(float gain)
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <SDL.h>
|
||||
#include "taiseigl.h"
|
||||
#include <math.h>
|
||||
|
||||
typedef struct {
|
||||
float r;
|
||||
|
|
|
@ -194,7 +194,7 @@ static size_t deflate_write(SDL_RWops *rw, const void *ptr, size_t size, size_t
|
|||
|
||||
if(available) {
|
||||
remaining -= copysize;
|
||||
memcpy(z->buffer_ptr, ptr + offset, copysize);
|
||||
memcpy(z->buffer_ptr, (uint8_t*)ptr + offset, copysize);
|
||||
printbuf(z->buffer_ptr, copysize);
|
||||
offset += copysize;
|
||||
z->buffer_ptr += copysize;
|
||||
|
|
|
@ -21,8 +21,8 @@ void init_vbo(VBO *vbo, int size) {
|
|||
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex)*size, NULL, GL_STATIC_DRAW);
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), NULL);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), NULL + sizeof(Vector));
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), NULL + 2*sizeof(Vector));
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), (uint8_t*)NULL + sizeof(Vector));
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (uint8_t*)NULL + 2*sizeof(Vector));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue