Thread: primary-expression error

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    1

    primary-expression error

    Code:
    1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string.h>
      4 #include <sys/ioctl.h>
      5 #include <sys/time.h>
      6 
      7 #define BS (32*1024)
      8 char buf0[BS];
      9 char buf1[BS];
     10 
     11 #define SWAP64(p) ( (*(unsigned __int64*)(p)) = _byteswap_uint64(*(unsigned __int64*)(p)) )
     12 
     13 int main(void)
     14 {
     15         int i,j;
     16         FILE *ff = fopen("testFdd.dat","rb");
     17         long pos0=0, pos1;
     18 
     19         long max_k = 15;
     20 
     21         while(1)
     22         {
     23                 memset(buf1,0,BS);
     24                 pos1 = ftell(ff);
     25                 if( fread(buf1,BS,1,ff) != 1 ) break;
     26                 for(i=0 ; i<BS-4 ; i++ )
     27                 {
     28                         if( memcmp(buf1+i,"/fdd",4)==0 )
     29                         {
     30                                 break;
     31                         }
     32                 }
     33                 if( i>=BS-4 ) continue; // didn't find
     34 
     35                 pos1 = pos1+i-0x40;
     36                 fseek(ff,pos1,SEEK_SET);
     37                 fread(buf1,1,BS,ff);
    38                 fseek(ff,pos1+0x41,SEEK_SET);
     39 
     40                 SWAP64(buf1);
     41                 SWAP64(buf1+0x18);
     42                 printf("%07x: %-7.7s %30s %lg %lg\n",pos1,buf1+8, buf1+0x20, *(double*)(buf1),*    (double*)(buf1+0x18));
     43                 int n = pos1-pos0;
     44                 if( n>BS ) n=BS;
     45                 if( pos0!=0 && max_k-- > 0 )
     46                 {
     47                         printf("\n");
     48                         for( i=256+64 ; i<n ; i+=8 )
     49                         {
     50                                 if( memcmp(buf0+i,buf1+i,8)!=0 )
     51                                 {
     52                                         SWAP64(buf1+i);
     53                                         printf("\t+%04x: %+21.15le -> %+21.15le  (%+16lg)\n",i,    *(double*)(buf0+i),*(double*)(buf1+i),*(double*)(buf1+i)-*(double*)(buf0+i));
     54                                 }
     55                         }
     56                         printf("\n");
     57                 }
     58 
     59                 pos0 = pos1;
     60                 memmove(buf0,buf1,n);
     61         }
     62 }
    I'm trying to compile the above code, but i get error: expected primary-expression before ‘unsigned’
    What is wrong with it? does anybody know?
    Thanks

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Did you accidentally posted this on the wrong board (this is C; not C++)?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Primary Expression Error Makes me Doubt my Grasp of Functions
    By chaucer345 in forum C++ Programming
    Replies: 8
    Last Post: 07-05-2012, 03:18 PM
  2. operator!= and primary-expression error : First time poster
    By kentrenholmpei in forum C++ Programming
    Replies: 2
    Last Post: 11-04-2011, 06:24 AM
  3. primary expression error when calling operation
    By elsparko in forum C++ Programming
    Replies: 2
    Last Post: 05-18-2010, 12:43 PM
  4. Replies: 24
    Last Post: 09-06-2006, 06:17 PM