×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Simon Coulter wrote:
I've tried a few things but I think the only way of making this work on
510 is to rewrite all 37 of the macro invocations to use a function
which can then support the varying argument list. Something like:
Simon, here's a way using text-substitution that's a bit carsick-making,
but it works:
#ifndef DEBUG_LOG
#if (__OS400_TGTVRM <= 520)
void debug_chk(int);
void debug_log(char *, ...);
#define DEBUG_LOG debug_chk(ch->flags & OTPW_DEBUG);debug_log
#else
#define DEBUG_LOG(...) if (ch->flags & OTPW_DEBUG) \
{ fprintf(stderr, __VA_ARGS__); fputc('\n',
stderr); }
#endif
#endif
The debug_chk() function would log the true/false value in a global
variable and then the debug_log() function would check the global before
doing the fprintf.
Here's my code:
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#define OTPW_DEBUG 1
#define DEBUG_LOG debug_chk(ch->flags & OTPW_DEBUG);debug_log
static int g_flag = 0;
void debug_chk(int flag)
{
g_flag = flag;
}
void debug_log( char * f, ...)
{
va_list args;
if (g_flag)
{
va_start( args, f );
vfprintf(stderr, f, args)
va_end( args );
fputc('\n', stderr);
}
}
main()
{
typedef struct
{
int flags;
} ch_t;
ch_t the_ch = {0xffffffff};
ch_t *ch = &the_ch;
DEBUG_LOG("hello");
DEBUG_LOG("there are %d %s", 2, "worlds");
DEBUG_LOG("hello %s", "world");
}
As an Amazon Associate we earn from qualifying purchases.