madvise is not available if _XPG4_2 is defined, g++ on Solaris will define 
_XPG4_2.
Use posix_madvise instead, or you can declare it in your program.

Ginn

On Aug 27, 2010, at 4:03 PM, Kishore Kumar Pusukuri wrote:

> Hi,
> I am trying to play with madvise on my AMD machine running 
> OpenSolaris.2009.06. However, getting the following error when I used to 
> compile the below program with /usr/sfw/bin/g++. Please help me to resolve 
> this. I am not sure whether the usage of madvise is correct or not? Please 
> let me know.
> 
> error: `madvise' undeclared (first use this function)
> error: (Each undeclared identifier is reported only once for each function it 
> appears in.)
> 
> Program
> =========
> ....
> #include <sys/types.h>
> #include <sys/mman.h>
> ...
> ...
> 
> int
> main (void)
> {
> ....
> 
>  int size = numOptions*sizeof(OptionData);
>  data = (OptionData*)malloc(size);
> 
>  if (data == NULL) {
>      perror("Fatal Error: malloc failed");
>      exit(-1);        
>  }
> 
>  int ret = madvise(data, size, MADV_ACCESS_MANY);
>  if (ret == -1) {
>      perror("Fatal Error: madvise failed");
>         exit(-2);
>  } 
>  ...
>  ...
> 
> return 0;
> }
> -- 
> This message posted from opensolaris.org
> _______________________________________________
> opensolaris-discuss mailing list
> opensolaris-discuss@opensolaris.org

_______________________________________________
opensolaris-discuss mailing list
opensolaris-discuss@opensolaris.org

Reply via email to