Variable Arguments and inline function.

Discussion in 'C++' started by Neo, Nov 24, 2006.

  1. Neo

    Neo Guest

    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.
    Neo, Nov 24, 2006
    #1
    1. Advertising

  2. * 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?
    Alf P. Steinbach, Nov 24, 2006
    #2
    1. Advertising

  3. Neo

    Neo Guest

    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?
    Neo, Nov 24, 2006
    #3
  4. Neo

    Neo Guest

    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?
    Neo, Nov 24, 2006
    #4
  5. Neo

    iftekhar Guest

    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?
    iftekhar, Nov 24, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nish
    Replies:
    4
    Views:
    479
    Thomas Stegen
    Oct 8, 2004
  2. TGOS
    Replies:
    3
    Views:
    366
    Kevin Bracey
    Feb 28, 2005
  3. jmborr
    Replies:
    1
    Views:
    398
    Stargaming
    Nov 3, 2007
  4. Replies:
    3
    Views:
    801
  5. Navaneeth
    Replies:
    4
    Views:
    540
    Kenny McCormack
    Nov 20, 2010
Loading...

Share This Page