Unexplained syntax error in variable definition

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MikeZZ
    New Member
    • Apr 2015
    • 3

    Unexplained syntax error in variable definition

    I'm trying to compile big piece of software which is X11 server on CentOS 7. During "make" I see this message:
    <file>:34 syntax error near:
    typedef unsigned short int __u_short;
    Line 34 is exactly as message quotes. I'm not much C programmer but this line looks good to me. Here are couple more lines not marked as errors:
    typedef unsigned char __u_char;
    typedef unsigned short int __u_short;
    typedef unsigned int __u_int;
    typedef unsigned long int __u_long;
    What is wrong with this code?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    There is no problem with the code you posted. All the error on line 34 means is that when the compiler got to line 34 there is an error. The error is on line 34 or 33 or 32 clear up to the beginning of the code.

    Start commenting out lines of code until it compiles. Then gradually remove the comments until the code fails to compile. There will be your actual error.

    Comment

    • MikeZZ
      New Member
      • Apr 2015
      • 3

      #3
      The problem is that the code is dynamically build by "make". The four lines I quote are first the first four lines after initial comments. I still don't see any problems with them.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Are you talking about the preprocessor generating code? Like there are macros at the beginning of the code? The "make" utility does not generate code.

        Maybe you could post the beginning of the file that has the problem.

        Comment

        • MikeZZ
          New Member
          • Apr 2015
          • 3

          #5
          The file is in /tmp directory, its name starts with tmp and then 6 random characters and qualifier .d, it also has blank lines
          Code:
          # 1 "./Xserver.d"
          # 1 "<built-in>"
          # 1 "<command-line>"
          # 1 "/usr/include/stdc-predef.h" 1 3 4
          # 1 "<command-line>" 2
          # 1 "./Xserver.d"
          # 31 "./Xserver.d"
          # 1 "/usr/include/sys/types.h" 1 3 4
          # 25 "/usr/include/sys/types.h" 3 4
          # 1 "/usr/include/features.h" 1 3 4
          # 375 "/usr/include/features.h" 3 4
          # 1 "/usr/include/sys/cdefs.h" 1 3 4
          # 392 "/usr/include/sys/cdefs.h" 3 4
          # 1 "/usr/include/bits/wordsize.h" 1 3 4
          # 393 "/usr/include/sys/cdefs.h" 2 3 4
          # 376 "/usr/include/features.h" 2 3 4
          # 399 "/usr/include/features.h" 3 4
          # 1 "/usr/include/gnu/stubs.h" 1 3 4
          # 10 "/usr/include/gnu/stubs.h" 3 4
          # 1 "/usr/include/gnu/stubs-64.h" 1 3 4
          # 11 "/usr/include/gnu/stubs.h" 2 3 4
          # 400 "/usr/include/features.h" 2 3 4
          # 26 "/usr/include/sys/types.h" 2 3 4
          
          
          
          # 1 "/usr/include/bits/types.h" 1 3 4
          # 27 "/usr/include/bits/types.h" 3 4
          # 1 "/usr/include/bits/wordsize.h" 1 3 4
          # 28 "/usr/include/bits/types.h" 2 3 4
          
          
          typedef unsigned char __u_char;
          typedef unsigned short int __u_short;
          typedef unsigned int __u_int;
          typedef unsigned long int __u_long;
          
          
          typedef signed char __int8_t

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            This code compiles fine:
            Code:
            typedef unsigned char __u_char;
            typedef unsigned short int __u_short;
            typedef unsigned int __u_int;
            typedef unsigned long int __u_long;
            
            
            typedef signed char __int8_t;
            I would create a new source code file and put these lines in it. Then I would compile the file to be sure everything is fine.

            Then above these lines I would add:

            Code:
            # 28 "/usr/include/bits/types.h" 2 3 4
            so the fie looks like:

            Code:
            # 28 "/usr/include/bits/types.h" 2 3 4
            
            typedef unsigned char __u_char;
            typedef unsigned short int __u_short;
            typedef unsigned int __u_int;
            typedef unsigned long int __u_long;
            
            
            typedef signed char __int8_t;
            and compile this. If this works add the next line, recompile and verify it still works. Keep working up until the compiler produces an error. The error should be in the last fle you added in.

            Comment

            Working...