I am testing a generic error handling function in C, and need some
feed back on 'Best Practices'.

I have a nested typedef structure for myEC that contains the variable
portion of the execption data. I've hard coded this at 100, but I have
also seen the Exeption data defined as large as 32767. What is the
best why to define the exception data?

Also, I have made the tyepdef Structure local to both main and
myFunction, so I believe that the compiler should define both
structures local to their functions.

Any other comments would be greatly appreciated.

Thanks,
Erick



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <qusec.h>


static int myFunction( void * pApiErrCd);
// local function

int main(void)
{
// Declare the nested error structure
typedef struct myEC
{
Qus_EC_t EC_Fixed;
char Exception_Data[100];
} myEC_t;

myEC_t ApiErrCd;
ApiErrCd.EC_Fixed.Bytes_Provided = sizeof(ApiErrCd);
ApiErrCd.EC_Fixed.Bytes_Available = 0;
myFunction(&ApiErrCd);
return 0;
}

int myFunction(void * pApiErrCd)
{
typedef struct myEC
{
Qus_EC_t EC_Fixed;
char Exception_Data[100];
} myEC_t;

myEC_t * ApiErrCd;

// Need to assign the pointer value passed
// within pApiErrCd
ApiErrCd = pApiErrCd;
return 0;
}

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].