typedef for a function for different platforms
-
Hi I have the same piece of code running on Windows and Zos (mainframe) is it possible to typedef the read I am getting a compile error saying before SYSREAD there should be a ";" thanks I.e.
#ifdef ZOS
size_t fread(void * __restrict__buffer, size_t size, size_t count, FILE * __restrict__stream) SYSREAD;
#ELSE
typedef BOOL ReadFileEx(HANDLE, LPVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE) SYSREAD;
#endif
HANDLE hFile; -
Hi I have the same piece of code running on Windows and Zos (mainframe) is it possible to typedef the read I am getting a compile error saying before SYSREAD there should be a ";" thanks I.e.
#ifdef ZOS
size_t fread(void * __restrict__buffer, size_t size, size_t count, FILE * __restrict__stream) SYSREAD;
#ELSE
typedef BOOL ReadFileEx(HANDLE, LPVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE) SYSREAD;
#endif
HANDLE hFile;That's not a valid typedef, and you cannot resolve your problem in this manner. You could create a typedef for a function that takes a certain list of parameters, and returns BOOL, but that would not then be tied to the function ReadFileEx as appears to be your intent. (and, on a sidenote, I'm not sure the compiler will eat that capitalized #ELSE) Just provide an adapter function for this purpose:
#ifdef ZOS
...
#else
BOOL SYSREAD(...)
{
return ReadFileEx(...);
}
#endifP.S.: NOw that I've reread the code you've written, I am no longer sure what it's supposed to do. I still think that an adapter function is what you need, but the syntax you've used above doesn't appear to make any sense under that assumption. So, if you intended something else, maybe you should point out what that code should do, or better yet, show a line of code or two that uses SYSREAD in the intended manner.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
Hi I have the same piece of code running on Windows and Zos (mainframe) is it possible to typedef the read I am getting a compile error saying before SYSREAD there should be a ";" thanks I.e.
#ifdef ZOS
size_t fread(void * __restrict__buffer, size_t size, size_t count, FILE * __restrict__stream) SYSREAD;
#ELSE
typedef BOOL ReadFileEx(HANDLE, LPVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE) SYSREAD;
#endif
HANDLE hFile; -
That's not a valid typedef, and you cannot resolve your problem in this manner. You could create a typedef for a function that takes a certain list of parameters, and returns BOOL, but that would not then be tied to the function ReadFileEx as appears to be your intent. (and, on a sidenote, I'm not sure the compiler will eat that capitalized #ELSE) Just provide an adapter function for this purpose:
#ifdef ZOS
...
#else
BOOL SYSREAD(...)
{
return ReadFileEx(...);
}
#endifP.S.: NOw that I've reread the code you've written, I am no longer sure what it's supposed to do. I still think that an adapter function is what you need, but the syntax you've used above doesn't appear to make any sense under that assumption. So, if you intended something else, maybe you should point out what that code should do, or better yet, show a line of code or two that uses SYSREAD in the intended manner.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)