Use SConscript configure support to probe for format(printf) attribute
This commit is contained in:
parent
77d69d0384
commit
ff90315978
11
SConstruct
11
SConstruct
|
@ -140,6 +140,17 @@ help:assume compiler supports __attribute__((format_arg))
|
||||||
self._check_macro(context,macro_name=macro_name,macro_value=macro_value,test="""
|
self._check_macro(context,macro_name=macro_name,macro_value=macro_value,test="""
|
||||||
char*a(char*)__attribute_format_arg(1);
|
char*a(char*)__attribute_format_arg(1);
|
||||||
""", msg='for function __attribute__((format_arg))')
|
""", msg='for function __attribute__((format_arg))')
|
||||||
|
@_custom_test
|
||||||
|
def check_attribute_format_printf(self,context):
|
||||||
|
"""
|
||||||
|
help:assume compiler supports __attribute__((format(printf)))
|
||||||
|
"""
|
||||||
|
macro_name = '__attribute_format_printf(A,B)'
|
||||||
|
macro_value = '__attribute__((format(printf,A,B)))'
|
||||||
|
self._check_macro(context,macro_name=macro_name,macro_value=macro_value,test="""
|
||||||
|
int a(char*,...)__attribute_format_printf(1,2);
|
||||||
|
int b(char*)__attribute_format_printf(1,0);
|
||||||
|
""", msg='for function __attribute__((format(printf)))')
|
||||||
|
|
||||||
class LazyObjectConstructor:
|
class LazyObjectConstructor:
|
||||||
def __lazy_objects(self,name,source):
|
def __lazy_objects(self,name,source):
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#define _CONSOLE_H_
|
#define _CONSOLE_H_
|
||||||
|
|
||||||
#include "pstypes.h"
|
#include "pstypes.h"
|
||||||
|
#include "dxxsconf.h"
|
||||||
|
|
||||||
/* Priority levels */
|
/* Priority levels */
|
||||||
#define CON_CRITICAL -3
|
#define CON_CRITICAL -3
|
||||||
|
@ -30,7 +31,7 @@ typedef struct console_buffer
|
||||||
} __pack__ console_buffer;
|
} __pack__ console_buffer;
|
||||||
|
|
||||||
void con_init(void);
|
void con_init(void);
|
||||||
void con_printf(int level, const char *fmt, ...);
|
void con_printf(int level, const char *fmt, ...) __attribute_format_printf(2, 3);
|
||||||
void con_showup(void);
|
void con_showup(void);
|
||||||
|
|
||||||
#endif /* _CONSOLE_H_ */
|
#endif /* _CONSOLE_H_ */
|
||||||
|
|
|
@ -21,22 +21,21 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#define _ERROR_H
|
#define _ERROR_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "dxxsconf.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define __noreturn __attribute__ ((noreturn))
|
#define __noreturn __attribute__ ((noreturn))
|
||||||
#define __attribute_gcc_format(X) __attribute__ ((format X))
|
|
||||||
#else
|
#else
|
||||||
#define __noreturn
|
#define __noreturn
|
||||||
#define __attribute_gcc_format(X)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void warn_printf(const char *s);
|
void warn_printf(const char *s);
|
||||||
int error_init(void (*func)(const char *)); //init error system, returns 0=ok
|
int error_init(void (*func)(const char *)); //init error system, returns 0=ok
|
||||||
void Warning(const char *fmt,...); //print out warning message to user
|
void Warning(const char *fmt,...) __attribute_format_printf(1, 2); //print out warning message to user
|
||||||
void set_warn_func(void (*f)(const char *s));//specifies the function to call with warning messages
|
void set_warn_func(void (*f)(const char *s));//specifies the function to call with warning messages
|
||||||
void clear_warn_func();//say this function no longer valid
|
void clear_warn_func();//say this function no longer valid
|
||||||
void Error(const char *fmt,...) __noreturn __attribute_gcc_format((printf, 1, 2)); //exit with error code=1, print message
|
void Error(const char *fmt,...) __noreturn __attribute_format_printf(1, 2); //exit with error code=1, print message
|
||||||
#define Assert assert
|
#define Assert assert
|
||||||
#ifndef NDEBUG //macros for debugging
|
#ifndef NDEBUG //macros for debugging
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#ifndef _EDITOR_H
|
#ifndef _EDITOR_H
|
||||||
#define _EDITOR_H
|
#define _EDITOR_H
|
||||||
|
|
||||||
|
#include "dxxsconf.h"
|
||||||
#include "vecmat.h"
|
#include "vecmat.h"
|
||||||
#include "segment.h"
|
#include "segment.h"
|
||||||
#include "inferno.h"
|
#include "inferno.h"
|
||||||
|
@ -481,7 +482,7 @@ extern void print_status_icon( char icon[1], int position );
|
||||||
extern void clear_status_icon( char icon[1], int position );
|
extern void clear_status_icon( char icon[1], int position );
|
||||||
|
|
||||||
// Editor status message.
|
// Editor status message.
|
||||||
extern void editor_status_fmt(const char *format, ... );
|
extern void editor_status_fmt(const char *format, ... ) __attribute_format_printf(1, 2);
|
||||||
|
|
||||||
// Variables in editor.c that the k*.c files need
|
// Variables in editor.c that the k*.c files need
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
|
|
||||||
#include "pstypes.h"
|
#include "pstypes.h"
|
||||||
#include "fix.h"
|
#include "fix.h"
|
||||||
|
#include "dxxsconf.h"
|
||||||
|
|
||||||
#ifdef DXX_BUILD_DESCENT_I
|
#ifdef DXX_BUILD_DESCENT_I
|
||||||
extern int HiresGFXAvailable;
|
extern int HiresGFXAvailable;
|
||||||
|
@ -328,8 +329,8 @@ void gr_set_curfont( grs_font * );
|
||||||
void gr_set_fontcolor( int fg_color, int bg_color );
|
void gr_set_fontcolor( int fg_color, int bg_color );
|
||||||
int gr_string(int x, int y, const char *s );
|
int gr_string(int x, int y, const char *s );
|
||||||
int gr_ustring(int x, int y, const char *s );
|
int gr_ustring(int x, int y, const char *s );
|
||||||
int gr_printf( int x, int y, const char * format, ... );
|
int gr_printf( int x, int y, const char * format, ... ) __attribute_format_printf(3, 4);
|
||||||
int gr_uprintf( int x, int y, const char * format, ... );
|
int gr_uprintf( int x, int y, const char * format, ... ) __attribute_format_printf(3, 4);
|
||||||
void gr_get_string_size(const char *s, int *string_width, int *string_height, int *average_width );
|
void gr_get_string_size(const char *s, int *string_width, int *string_height, int *average_width );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <physfs/physfs.h>
|
#include <physfs/physfs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "dxxsconf.h"
|
||||||
#include "pstypes.h"
|
#include "pstypes.h"
|
||||||
#include "strutil.h"
|
#include "strutil.h"
|
||||||
#include "u_mem.h"
|
#include "u_mem.h"
|
||||||
|
@ -188,6 +189,7 @@ static inline char * PHYSFSX_fgets(char *buf, size_t n, PHYSFS_file *const fp)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int PHYSFSX_printf(PHYSFS_file *file, const char *format, ...) __attribute_format_printf(2, 3);
|
||||||
static inline int PHYSFSX_printf(PHYSFS_file *file, const char *format, ...)
|
static inline int PHYSFSX_printf(PHYSFS_file *file, const char *format, ...)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
|
|
|
@ -20,6 +20,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#ifndef _UI_H
|
#ifndef _UI_H
|
||||||
#define _UI_H
|
#define _UI_H
|
||||||
|
|
||||||
|
#include "dxxsconf.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
|
||||||
struct window;
|
struct window;
|
||||||
|
@ -261,7 +262,7 @@ extern int ui_scrollbar_do( UI_DIALOG *dlg, UI_GADGET_SCROLLBAR * scrollbar, str
|
||||||
extern void ui_draw_scrollbar( UI_DIALOG *dlg, UI_GADGET_SCROLLBAR * scrollbar );
|
extern void ui_draw_scrollbar( UI_DIALOG *dlg, UI_GADGET_SCROLLBAR * scrollbar );
|
||||||
|
|
||||||
|
|
||||||
extern void ui_dprintf_at( UI_DIALOG * dlg, short x, short y, const char * format, ... );
|
extern void ui_dprintf_at( UI_DIALOG * dlg, short x, short y, const char * format, ... ) __attribute_format_printf(4, 5);
|
||||||
|
|
||||||
extern void ui_draw_radio( UI_DIALOG *dlg, UI_GADGET_RADIO * radio );
|
extern void ui_draw_radio( UI_DIALOG *dlg, UI_GADGET_RADIO * radio );
|
||||||
extern UI_GADGET_RADIO * ui_add_gadget_radio( UI_DIALOG * dlg, short x, short y, short w, short h, short group, const char * text );
|
extern UI_GADGET_RADIO * ui_add_gadget_radio( UI_DIALOG * dlg, short x, short y, short w, short h, short group, const char * text );
|
||||||
|
|
|
@ -20,6 +20,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#ifndef _AI_H
|
#ifndef _AI_H
|
||||||
#define _AI_H
|
#define _AI_H
|
||||||
|
|
||||||
|
#include "dxxsconf.h"
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#if defined(DXX_BUILD_DESCENT_II)
|
#if defined(DXX_BUILD_DESCENT_II)
|
||||||
#include "fvi.h"
|
#include "fvi.h"
|
||||||
|
@ -314,7 +315,7 @@ extern int Buddy_objnum, Buddy_allowed_to_talk;
|
||||||
|
|
||||||
extern void start_robot_death_sequence(object *objp);
|
extern void start_robot_death_sequence(object *objp);
|
||||||
extern int do_any_robot_dying_frame(object *objp);
|
extern int do_any_robot_dying_frame(object *objp);
|
||||||
extern void buddy_message(const char * format, ... );
|
extern void buddy_message(const char * format, ... ) __attribute_format_printf(1, 2);
|
||||||
|
|
||||||
#define SPECIAL_REACTOR_ROBOT 65
|
#define SPECIAL_REACTOR_ROBOT 65
|
||||||
extern void special_reactor_stuff(void);
|
extern void special_reactor_stuff(void);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _HUD_MSG_H
|
#define _HUD_MSG_H
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include "dxxsconf.h"
|
||||||
|
|
||||||
#define HUD_MESSAGE_LENGTH 150
|
#define HUD_MESSAGE_LENGTH 150
|
||||||
#define HUD_MAX_NUM_DISP 4
|
#define HUD_MAX_NUM_DISP 4
|
||||||
|
@ -16,8 +17,8 @@
|
||||||
extern int HUD_toolong;
|
extern int HUD_toolong;
|
||||||
extern void HUD_clear_messages();
|
extern void HUD_clear_messages();
|
||||||
extern void HUD_render_message_frame();
|
extern void HUD_render_message_frame();
|
||||||
int HUD_init_message(int class_flag, const char * format, ... );
|
int HUD_init_message(int class_flag, const char * format, ... ) __attribute_format_printf(2, 3);
|
||||||
int HUD_init_message_va(int class_flag, const char * format, va_list args);
|
int HUD_init_message_va(int class_flag, const char * format, va_list args) __attribute_format_printf(2, 0);
|
||||||
int HUD_init_message_literal(int class_flag, const char *str);
|
int HUD_init_message_literal(int class_flag, const char *str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,6 +21,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#ifndef _POWERUP_H
|
#ifndef _POWERUP_H
|
||||||
#define _POWERUP_H
|
#define _POWERUP_H
|
||||||
|
|
||||||
|
#include "dxxsconf.h"
|
||||||
#include "vclip.h"
|
#include "vclip.h"
|
||||||
|
|
||||||
enum powerup_type_t
|
enum powerup_type_t
|
||||||
|
@ -133,7 +134,7 @@ extern void diminish_towards_max(void);
|
||||||
|
|
||||||
extern void do_megawow_powerup(int quantity);
|
extern void do_megawow_powerup(int quantity);
|
||||||
|
|
||||||
extern void powerup_basic(int redadd, int greenadd, int blueadd, int score, const char *format, ...) __attribute_gcc_format((printf, 5, 6));
|
extern void powerup_basic(int redadd, int greenadd, int blueadd, int score, const char *format, ...) __attribute_format_printf(5, 6);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* reads n powerup_type_info structs from a PHYSFS_file
|
* reads n powerup_type_info structs from a PHYSFS_file
|
||||||
|
|
|
@ -72,7 +72,8 @@ char *object_ids(int objnum)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void err_printf(PHYSFS_file *my_file, char * format, ... )
|
static void err_printf(PHYSFS_file *my_file, char * format, ... ) __attribute_format_printf(2, 3);
|
||||||
|
static void err_printf(PHYSFS_file *my_file, char * format, ... )
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char message[256];
|
char message[256];
|
||||||
|
@ -86,7 +87,8 @@ void err_printf(PHYSFS_file *my_file, char * format, ... )
|
||||||
Errors_in_mine++;
|
Errors_in_mine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void warning_printf(PHYSFS_file *my_file, char * format, ... )
|
static void warning_printf(PHYSFS_file *my_file, char * format, ... ) __attribute_format_printf(2, 3);
|
||||||
|
static void warning_printf(PHYSFS_file *my_file, char * format, ... )
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char message[256];
|
char message[256];
|
||||||
|
|
|
@ -787,7 +787,8 @@ int draw_rock(newmenu *menu, d_event *event, grs_bitmap *background)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_screen_message(char *fmt, ...)
|
static void do_screen_message(const char *fmt, ...) __attribute_format_printf(1, 2);
|
||||||
|
static void do_screen_message(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
grs_bitmap background;
|
grs_bitmap background;
|
||||||
|
|
|
@ -87,7 +87,8 @@ char *object_ids(int objnum)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void err_printf(PHYSFS_file *my_file, char * format, ... )
|
static void err_printf(PHYSFS_file *my_file, char * format, ... ) __attribute_format_printf(2, 3);
|
||||||
|
static void err_printf(PHYSFS_file *my_file, char * format, ... )
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char message[256];
|
char message[256];
|
||||||
|
@ -101,7 +102,8 @@ void err_printf(PHYSFS_file *my_file, char * format, ... )
|
||||||
Errors_in_mine++;
|
Errors_in_mine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void warning_printf(PHYSFS_file *my_file, char * format, ... )
|
static void warning_printf(PHYSFS_file *my_file, char * format, ... ) __attribute_format_printf(2, 3);
|
||||||
|
static void warning_printf(PHYSFS_file *my_file, char * format, ... )
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char message[256];
|
char message[256];
|
||||||
|
|
|
@ -426,7 +426,8 @@ void buddy_message(const char * format, ... )
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void thief_message(const char * format, ... )
|
static void thief_message(const char * format, ... ) __attribute_format_printf(1, 2);
|
||||||
|
static void thief_message(const char * format, ... )
|
||||||
{
|
{
|
||||||
|
|
||||||
char gb_str[16], new_format[128];
|
char gb_str[16], new_format[128];
|
||||||
|
|
|
@ -945,7 +945,8 @@ int draw_stars_bg(newmenu *menu, d_event *event, grs_bitmap *background)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_screen_message(char *fmt, ...)
|
static void do_screen_message(const char *fmt, ...) __attribute_format_printf(1, 2);
|
||||||
|
static void do_screen_message(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
grs_bitmap background;
|
grs_bitmap background;
|
||||||
|
|
|
@ -134,7 +134,9 @@ void print_clock( int seconds, char message[10] ) {
|
||||||
|
|
||||||
static char the_time[14]; // changed from 10, I don't think that was long enough
|
static char the_time[14]; // changed from 10, I don't think that was long enough
|
||||||
|
|
||||||
void clock_message( int seconds, char *format, ... ) {
|
static void clock_message( int seconds, const char *format, ... ) __attribute_format_printf(2, 3);
|
||||||
|
static void clock_message( int seconds, const char *format, ... )
|
||||||
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
|
|
@ -265,7 +265,8 @@ void scores_maybe_add_player(int abort_flag)
|
||||||
window_close(Game_wind); // prevent the next game from doing funny things
|
window_close(Game_wind); // prevent the next game from doing funny things
|
||||||
}
|
}
|
||||||
|
|
||||||
void scores_rprintf(int x, int y, char * format, ... )
|
static void scores_rprintf(int x, int y, const char * format, ... ) __attribute_format_printf(3, 4);
|
||||||
|
static void scores_rprintf(int x, int y, const char * format, ... )
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
|
|
Loading…
Reference in a new issue