Don't know but could the problem be that you simply need to put the macro into context? eg:
Code:
#include <stdio.h>
#define JPDM_NAME_SIZE 16
#define JPDM_DECLARE_BUFFER_DESCRIPTION(name, ptr, size)\
{ \
JPDM_RECOVERY_STATE_NONE, \
name, \
(ptr), \
(size), \
NULL, \
0 \
}
typedef enum
{
JPDM_RECOVERY_STATE_NONE,
JPDM_RECOVERY_STATE_NEW,
JPDM_RECOVERY_STATE_RECOVERED,
JPDM_RECOVERY_STATE_SAVED
} teRecoveryState;
struct BuffS { int state1; /* #### just guessing at this struct name and members... */
char * name;
void * p1;
size_t sz;
void* p2;
int state2;
};
int main(void)
{
int sSwitch = 5; /* #### guessing at these vars too */
char tsSwitch[] = "And the last to go will get to watch the others go before her... hahahaha";
/* Following statement gives error #### see how it now is a struct initializtion? */
struct BuffS bf1 = JPDM_DECLARE_BUFFER_DESCRIPTION("Anoop", &sSwitch, sizeof(tsSwitch));
printf("bf1.state1=%d name=%s p1=%p sz=%u state2=%d &sSwitch= %p \n",
bf1.state1, bf1.name, bf1.p1, bf1.sz, bf1.state2, (void*)&sSwitch );
return 0;
}
/*
~> gcc -Wall -W -pedantic 100427_macro-00.c -o 100427_macro-00
100427_macro-00.c: In function ‘main’:
100427_macro-00.c:37: warning: initializer element is not computable at load time #### refers to: &sSwitch
100427_macro-00.c:37: warning: unused variable ‘bf1’
~>
#### no segfault at run
~> ./100427_macro-00
bf1.state1=0 name=Anoop p1=0xbfeea0f4 sz=74 state2=0 &sSwitch= 0xbfeea0f4
~>
#### a look at the expanded macro:
~> cc -E 100427_macro-00.c -o 100427_macro-00
~> vi 100427_macro-00
...
int main(void)
{
...
struct BuffS bf1 = { JPDM_RECOVERY_STATE_NONE, "Anoop", (&sSwitch), (sizeof(tsSwitch)), ((void *)0), 0 };
return 0;
}
*/
I guess it works? Good exercise anyhow.