Variable Arguments and inline function.

N

Neo

Hi All,
Can I write a variable argument function as inline function? and will
it be inline always? if not, can I force it to be line on all platforms.
 
A

Alf P. Steinbach

* Neo:
Hi All,
Can I write a variable argument function as inline function?

Yes. But there are seldom good reasons to use "...". It's in a
category under 'goto' among things not to use (except for compile time
code).

and will it be inline always?

Depends on the compiler etc.

if not, can I force it to be line on all platforms.

Depends on the compiler etc.
 
N

Neo

Let me define my problem neatly.

I want a function say

Log(param1,param2,...)
param1= compulsory
param2=compulsory
.... = any

Purpose of this function is to log any general info.
Also __FILE__ and __LINE__ macros will be inside this function.

Now this function should expand at a place where it is used so that
__FILE__ and __LINE__ macros will work properly. That made me to think
of "inline".


Also I should able to use variable arguments and I want this function
as a member of one class.


Thanks
Vikram S
 
N

Neo

Let me define my problem neatly.

I want a function say

Log(param1,param2,...)
param1= compulsory
param2=compulsory
.... = any

Purpose of this function is to log any general info.
Also __FILE__ and __LINE__ macros will be inside this function.

Now this function should expand at a place where it is used so that
__FILE__ and __LINE__ macros will work properly. That made me to think
of "inline".


Also I should able to use variable arguments and I want this function
as a member of one class.


Thanks
Vikram S
 
I

iftekhar

Hi Neo

IMHO you should use a macro rather than a inline function, since inline
is merely a request (far as i know ) and up to the compiler to decide.

it could be something like

#define Log(...) logger(__FILE__, __LINE__, ...)

hope it helps

iftekhar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top