The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
AWK CSV to TXT format, TXT file not in a correct column format mdap Shell Programming and Scripting 1 08-14-2008 11:03 AM
To convert multi format file to a readable ascii format gaur.deepti UNIX for Dummies Questions & Answers 5 03-25-2008 03:03 PM
Convert UTF8 Format file to ANSI format rajreddy UNIX for Dummies Questions & Answers 9 05-25-2007 08:26 AM
Convert UTF8 Format file to ANSI format rajreddy UNIX for Advanced & Expert Users 1 05-24-2007 06:40 AM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-27-2006 11:30 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-29-2009
konvalo konvalo is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 17
Question warning: int format,pid_t arg (arg 2)

I try following code under Solaris10,like follows:

Code:
int glob = 6;
int main(void)
{
  int var;
  pid_t pid;
  var = 88;
  printf("before vfork\n");
  if ((pid = vfork()) < 0) {
    err_sys("vfork error");
  } else if (pid == 0) { 
      glob++;
     var++;
     _exit(0);
  }
  printf("pid = %d, glob = %d, var = %d\n", getpid(), glob, var);
  exit(0);
}
When I compile it,it raise following warning
$gcc -Wall abc.c error.obj
abc.c: In function 'main':
abc.c:16: warning: int format,pid_t arg (arg 2)
ld: warning: symbol 'glob' has differing types:
(file /var/tmp//ccIMPxLe.o type=OBJT; file/usr/lib/libc.so type=FUNC);
/var/tmp//ccIMPxLe.o definition take
ld: warning: symbol 'glob' has differing types:
(file /var/tmp//ccIMPxLe.o type=OBJT; file/usr/lib/libc.so type=FUNC);

Why raise above warning? How to correct it?

Thanks in advance
  #2 (permalink)  
Old 06-29-2009
mgessner mgessner is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 50
Because pid's differ widely across systems, the only thing you can really do (aside from changing printf() and adding a new class of object) is to cast intelligently:

Code:
printf ("pid = %lu\n", (unsigned long) getpid());
It's a reasonable assumption that a PID is an unsigned integer type.

HTH. YMMV.
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0