LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices


Reply
  Search this Thread
Old 05-26-2004, 03:38 AM   #1
vincentfclarke
LQ Newbie
 
Registered: May 2004
Posts: 1

Rep: Reputation: 0
Variable arguments in C macros on AIX


I am currently working on the recompilation of source code written on a Sequent Numa system to be run on an RS6000 AIX 5.2.

I have a problem with trying to convert some C code which attempts to use macros with variable arguments.

The problem is as. The following is a code fragment which when inserted into source code on the Sequent will compile and work correctly.

#define WDEBUG(format, args...) fprintf(stderr, "line %d: ", format "\n", '__LINE__' , ## args)

However when the same source code is compiled on the AIX it produces the following compilation error.

cc -c -g -DAIX -DTHREADSAFE -I/usr/iws/include -I../lib -DMYTYPE=906 -DLIVE=1 test.c

test.c", line 52.28: 1506-211 (S) Parameter list must be empty, or consist of one or more identifiers separated by commas.

As I'm not the author of the source code I'm not entirely sure what is being attempted here. But it seems to me that the Sequent can handle variable arguments in a macro where the AIX cannot.

I'd appreciate any help in finding a solution to this problem.
 
Old 05-27-2004, 12:06 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
The AIX Visual Age compiler does not seem to like variable argument macros. It does look like gcc supports them though.

How about a function? This would mean that you would not have to change any of the calls.
Code:
int WDEBUG( char * format, ... )
{
  va_list va_alist;
  va_start ( va_alist, format );
  vfprintf(stderr,  format, va_alist );
  va_end( va_alist );
}
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros In C drumstick Programming 8 11-21-2005 04:37 PM
BASH Script: variable values referencing for console arguments sadarax Programming 1 11-14-2005 05:23 PM
Macros Twi7ch Linux - General 2 08-27-2005 09:37 PM
php mysql variable arguments in query. ldp Linux - Software 0 10-26-2004 07:56 AM
System hangs in update of AIX from 4.3.3 to AIX 5.2 jmurray67 AIX 2 07-25-2004 08:25 PM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 02:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration