Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Variable Arguments and inline function.

Reply
Thread Tools

Variable Arguments and inline function.

 
 
Neo
Guest
Posts: n/a
 
      11-24-2006
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.

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      11-24-2006
* 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.



--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
 
Neo
Guest
Posts: n/a
 
      11-24-2006
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




Alf P. Steinbach wrote:
> * 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.
>
>
>
> --
> A: Because it messes up the order in which people normally read text.
> Q: Why is it such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?


 
Reply With Quote
 
Neo
Guest
Posts: n/a
 
      11-24-2006
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




Alf P. Steinbach wrote:
> * 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.
>
>
>
> --
> A: Because it messes up the order in which people normally read text.
> Q: Why is it such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?


 
Reply With Quote
 
iftekhar
Guest
Posts: n/a
 
      11-24-2006
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



Neo wrote:
> 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
>
>
>
>
> Alf P. Steinbach wrote:
> > * 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.
> >
> >
> >
> > --
> > A: Because it messes up the order in which people normally read text.
> > Q: Why is it such a bad thing?
> > A: Top-posting.
> > Q: What is the most annoying thing on usenet and in e-mail?


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a function that expects variable arguments from a functionwith variable arguments Navaneeth C Programming 4 11-20-2010 05:35 AM
Call again a variadic function (... variable number of arguments)with same arguments that its variadic wrapper moreau.steve@gmail.com C Programming 3 12-31-2008 07:13 AM
Multiple functions (one version being inline and other beingnon-inline) Rahul C++ 3 02-28-2008 03:28 PM
about extern inline and static inline Sean C++ 4 04-30-2006 03:18 PM
inline or not to inline in C++ Abhi C++ 2 07-03-2003 12:07 AM



Advertisments