Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. typedef for a function for different platforms

typedef for a function for different platforms

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    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;

    S L 2 Replies Last reply
    0
    • F ForNow

      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;

      S Offline
      S Offline
      Stefan_Lang
      wrote on last edited by
      #2

      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(...);
      }
      #endif

      P.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)

      F 1 Reply Last reply
      0
      • F ForNow

        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;

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You forgot the typedef keyword.

        F 1 Reply Last reply
        0
        • S Stefan_Lang

          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(...);
          }
          #endif

          P.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)

          F Offline
          F Offline
          ForNow
          wrote on last edited by
          #4

          thanks

          1 Reply Last reply
          0
          • L Lost User

            You forgot the typedef keyword.

            F Offline
            F Offline
            ForNow
            wrote on last edited by
            #5

            thanks

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups