1
0
mirror of http://mpg123.de/trunk/.git synced 2025-04-19 16:02:16 +03:00
mpg123/test_c99.c
thor 72157adde6 build, general: Reduce type and header checking, assume more C99
This introduces a single compile check that ensures that a number of
assumed C99 features are there. A number of HAVE_FOO_H and SIZEOF_FOO
macros are gone now. We just use standard C99 headers.

A similar grouped test should follow for POSIX stuff. A bit less
cruft in configure logic and preprocessing. Lots of SIZE_P and
similar are gone, also fixing a number of occasions where
the debug printf format didn't match the suppplied type (cast
missing).



git-svn-id: svn://scm.orgis.org/mpg123/trunk@5377 35dc7657-300d-0410-a2e5-dc2837fedb53
2023-10-05 20:40:48 +00:00

51 lines
1.6 KiB
C

// A little test program to group compile tests for standard C99 features
// we expect for mpg123 code. It is silly testing all headers and types
// individually, and unnecessarily slow. We mention all of the expected
// ones here and still fail early with a useful error for the user at
// configure stage.
/* This also nicely documents which features are expected. */
// Basic stuff. exit()
#include <stdlib.h>
// For the fixed-width integer types.
#include <stdint.h>
// For PRI macros.
#include <inttypes.h>
// ptrdiff_t, size_t
#include <stddef.h>
// _MAX/_MIN
#include <limits.h>
// printf
#include <stdio.h>
// strcmp, strlen
// remember: strcasecmp is POSIX, strings.h (sometimes)
#include <string.h>
int main()
{
const char *s = "some test string";
// Mention some types we want to use.
size_t st = 1337;
ptrdiff_t pt = 0x3443; // used instead of non-standard ssize_t
uint16_t u16 = 42;
uint32_t u32 = 23<<20;
int16_t i16 = 33;
int32_t i32 = -1*(21L<<20);
int64_t i64 = -1*(34L<<40);
uintmax_t um = 304203;
intmax_t im = -23434;
printf( "formats: "
"%s" " %s" " %s" " %s" " %s" " %s" " %s" " %s" " %s " "\n"
, "zu", PRIiMAX, PRIu16, PRIu32, PRIi16, PRIi32, PRIi64, PRIuMAX, PRIiMAX );
printf( "values:"
" %zu" " %"PRIiMAX " %"PRIu16 " %"PRIu32 " %"PRIi16 " %"PRIi32 " %"PRIi64 " %"PRIuMAX " %"PRIiMAX "\n"
, st, pt, u16, u32, i16, i32, i64, um, im );
printf("%ld <= long <= %ld\n", LONG_MIN, LONG_MAX);
printf( "The test string is %zu bytes long and compares to frick as %d\n"
, strlen(s), strcmp(s, "frick") );
exit(EXIT_SUCCESS);
}