473,414 Members | 1,643 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

C macro for ellipsis(...)

Hi I'd like to write a macro for the function with a variable argument, for example

Expand|Select|Wrap|Line Numbers
  1. #define PrivateLog(szFormat,...) \
  2.           PublicLogWrite(_TODAY_,szFormat,...)
  3. // where _TODAY_ is a static string containing e.g. "May 23, 2007"
  4.  
  5. void PublicLogWrite( char *szToday, char *szFmt, ... )
  6. {
  7.     va_list arglist;
  8.     va_start( arglist, szFmt );
  9.     // ... e.g. vsprintf()
  10.     va_end( arglist );
  11.     // ... e.g. fprintf()
  12. }
so the caller should look like,
PrivateLog( "Error:%s ReturnCode=%d\n", szErrorMessage, nError );
PrivateLog( "Info:%s Len=%d #Lines=%d\n", szInfoMessage, nLen, nNumLines );

But those 2 lines generates the compilation errors:
error C2059: syntax error : '...'

Anyone knows how to resolve this?
TIA.
May 23 '07 #1
1 4324
AdrianH
1,251 Expert 1GB
Hi I'd like to write a macro for the function with a variable argument, for example

Expand|Select|Wrap|Line Numbers
  1. #define PrivateLog(szFormat,...) \
  2.           PublicLogWrite(_TODAY_,szFormat,...)
  3. // where _TODAY_ is a static string containing e.g. "May 23, 2007"
  4.  
  5. void PublicLogWrite( char *szToday, char *szFmt, ... )
  6. {
  7.     va_list arglist;
  8.     va_start( arglist, szFmt );
  9.     // ... e.g. vsprintf()
  10.     va_end( arglist );
  11.     // ... e.g. fprintf()
  12. }
so the caller should look like,
PrivateLog( "Error:%s ReturnCode=%d\n", szErrorMessage, nError );
PrivateLog( "Info:%s Len=%d #Lines=%d\n", szInfoMessage, nLen, nNumLines );

But those 2 lines generates the compilation errors:
error C2059: syntax error : '...'

Anyone knows how to resolve this?
TIA.
See here. If your compiler predates C9x standard, it will not work.


Adrian
May 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chris Perkins | last post by:
Is there a reason why the ... notation as a literal for Ellipsis is only allowed inside a slice? Would allowing it elsewhere frighten the parser? Chris Perkins
6
by: Jonas Kölker | last post by:
so, I've read the manuals, done a few hacks, read the quick reference. however, one thing still eludes me: what (the hell) is Ellipsis? what's it good for? how do I use it; how does the...
9
by: Jerry Sievers | last post by:
Fellow Pythonists; I am totally puzzled on the use of slicing on mapping types and especially unsure on use of the Ellipsis... and slicing syntax that has two or more groups seperated by comma....
44
by: Simon Morgan | last post by:
Hi, Can somebody please help me grok the offsetof() macro? I've found an explanation on http://www.embedded.com/shared/printableArticle.jhtml?articleID=18312031 but I'm afraid it still...
2
by: marss | last post by:
IE allows to show text that exceeds the container's boundaries as unfinished (by adding ellipsis). e.g.: <div style="text-overflow:ellipsis;overflow:hidden;width:20px">some long text</div>...
10
by: Praveen.Kumar.SP | last post by:
Hi Could anyone solve the problem for the code below The Code: #include "stdio.h" #include "iostream.h" void Temp( int a, char* str,...)
5
by: saby | last post by:
I am using something like below which is working fine on solaris (sun studio 10). ------------------------------ #define START_LOG( p_aLevel, p_aFormat, ... ) \ if (p_aLevel >...
9
by: Two-Horned Unicorn | last post by:
The following code compiles and works as expected when compiled with gcc. /* empty-args.c */ #include <stdio.h> #define foo(x,y) puts("bar: x=\"" #x "\"; y=\"" #y "\"") #define bar(x) ...
12
by: webinfinite | last post by:
#define D(y...) (const int ) {y} My understand is that D is taking in a various length parameter y which is an array of const int. Am I right? Thanks.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.