The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compilation problem on HP-UX varuntayur High Level Programming 1 02-19-2008 11:07 AM
compilation problem phani_sree High Level Programming 2 10-25-2007 01:18 PM
compilation problem mansoorulhaq SUN Solaris 0 10-19-2007 05:18 AM
fread64 fwrite64 compilation problem (undefined symbol) Isax50 High Level Programming 3 08-16-2005 12:26 AM
gcc compilation collins High Level Programming 3 01-19-2005 09:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-31-2007
Registered User
 

Join Date: Oct 2007
Posts: 15
Compilation problem with semtimedop

Hi,

I'm porting code from Windows to HP-UX 11, compiling with gcc.
I have a call to semtimedop with 4 arguments as in the definition:
Code:
int semtimedop(int, struct sembuf *, unsigned int, const struct timespec *);
When compiling I get an error saying:
error: 'semtimedop' was not declared in this scope

I looked in /usr/include/sys/sem.h to see what compilation flags are needed, and it seems to me that there is an anomally there. In the excerpt from sem.h at the bootom, I have left the ifdefs and removed the code between them (faithfully, I hope) until the definition of semtimedop. As I understand it, it is impossible to reach the correct definition of semtimedop with arguments, since on the one hand it is under a global
Code:
#ifdef _INCLUDE_XOPEN_SOURCE
but on the other hand within this global ifdef it is under the else: of:
Code:
if defined(_INCLUDE_XOPEN_SOURCE) || defined(__LP64__)
This leaves me only with the definition of semtimedop as:
Code:
     extern int semtimedop();
which does not please the compiler.

Am I wrong? What is the correct way to solve this?

Thank you,

Rimon

Edited excerpt from sem.h:
Code:
#ifdef _INCLUDE_XOPEN_SOURCE


#  ifndef _NO_USER_PROTOS


#  ifdef _PROTOTYPES

#   if defined(_INCLUDE_XOPEN_SOURCE) || defined(__LP64__)
     extern int semop(int, struct sembuf *, size_t);
#   else /* not XOPEN_SOURCE or LP64 */
     extern int semop(int, struct sembuf *, unsigned int);
#    ifdef _INCLUDE_HPUX_SOURCE
      extern int semtimedop(int, struct sembuf *, unsigned int, const struct timespec *);
#    endif /* _INCLUDE_HPUX_SOURCE */
#   endif /* not XOPEN_SOURCE or LP64 */
#  else /* not _PROTOTYPES */
     extern int semctl();
     extern int semget();
     extern int semop();
#    ifdef _INCLUDE_HPUX_SOURCE
      extern int semtimedop();
#    endif /* _INCLUDE_HPUX_SOURCE */
#  endif /* not _PROTOTYPES */

#  ifdef __cplusplus
     }
#  endif /* __cplusplus */
#  endif /* not _NO_USER_PROTOS */
#endif /* _INCLUDE_XOPEN_SOURCE */
Reply With Quote
Forum Sponsor
  #2  
Old 10-31-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by rimon View Post
I'm porting code from Windows to HP-UX 11, compiling with gcc.
What code are you porting? I do the following mapping:

Win32 Event -> pthread_cond_t

Win32 Mutex -> pthread_mutex_t

On HPUX, I use

-D_XOPEN_SOURCE_EXTENDED -D_REENTRANT
Reply With Quote
  #3  
Old 11-01-2007
Registered User
 

Join Date: Oct 2007
Posts: 15
The relevant portion of the code I am porting manages semphores between the threads in my application. The specific call which gives me the compliation error is:
Code:
               rc = semtimedop(*sem_idp, sops, nsops, t_spec);
I tried the flags you mention but I'm afraid they don't solve the problem - I still get the compilation error.
Reply With Quote
  #4  
Old 11-01-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by rimon View Post
The relevant portion of the code I am porting manages semphores between the threads in my application.
I recommend you use a pthread construct to do what you want to do, or build a semaphore using a pthread condition.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0