Menu

Portable Integer Types

2002-12-05
2012-09-26
  • Nobody/Anonymous

    When I type the following program in, I get the error that "14 C:\....\Portable Types.cpp
    parse error before string constant ":

    #include <iostream>
    #include <stdlib.h>
    #include <stdio.h>
    #include <inttypes.h>

    int main()
    {
     
      int16_t me16;             //me16 is a 16-bit signed variable
      me16 = 4593;
      printf("First, assume int16_t is short: ");
      printf("me16 = %hd\n", me16);
      printf("Next, we make no assumptions, but use a \&quot;macro\&quot; from inttypes.h: ");
      printf("me16 = %" PRId16 "\n", me16);
     
      system("PAUSE");   
      return 0;
    }

    However, if I only type in:

    #include <iostream>
    #include <stdlib.h>
    #include <stdio.h>
    #include <inttypes.h>

    int main()
    {
     
      int16_t me16;             //me16 is a 16-bit signed variable
      me16 = 4593;
      printf("First, assume int16_t is short: ");
      printf("me16 = %hd\n", me16);
     
      system("PAUSE");   
      return 0;
    }

    I get no errors and DevCpp compiles a perfectly usable program.  I'm treating both as C++ programs, and using the new MinGW 3.2 compiler.

    What's going on?

    TIA,

       anon

     
    • Nobody/Anonymous

      well... there is a parse error... on line 14... apparently... you are reading something wrong... or the headers aren't doing something you that is assumed... anyway... the PRId16 is not being defined as "d"... either you can define it yourself or comment out the if block that is keeping it from being defined... or... maybe someone else has a better idea...

      Zero Valintine

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.