Results 1 to 3 of 3

Thread: [RESOLVED]return(*var=0,NULL);

  1. #1

    Thread Starter
    Addicted Member Phenix's Avatar
    Join Date
    Sep 2002
    Location
    Near A Cube
    Posts
    228

    [RESOLVED]return(*var=0,NULL);

    I am trying to compile code on MinGW for Mac and now I notice the code has a construct I've never seen, which compiled on VC++ 6.0 and VC++ Express.

    SomeStruct* CMyClass::MyMethod(const char *symbol,const int period,const time_t lasttime,int *count)

    {

    if(Something==NULL) return(*count=0,NULL);

    return Something(m_somevar,symbol,period,lasttime,count);

    }

    count is not a member of SomeStruct, so I assume it is just setting the value count points to equal to 0, then returning NULL.

    So does this do the same thing:

    if(Something==NULL) {
    *count=0;
    return(NULL);
    }
    return Something(m_somevar,symbol,period,lasttime,count);

    Or is there a switch I can pass to MinGW to let it accept the original return construct?
    Last edited by Phenix; Jul 31st, 2007 at 01:00 PM. Reason: [RESOLVED]
    Circa 1995
    Engineer - I think we should put our website address on our paper catalogs.
    Vice President - Don't get too excited about this internet thing.


    I am sorry, but the Oracle was mistaken. You cannot help us.
    -Matrix video game


    I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. ... and it probably never will support anything other than AT-harddisks, as that's all I have :-(.
    -Linus


    Question. Do you know that the character "?" means I'm asking a question? Question. Do you know that spoken inflection also provides the same cue? So please don't say, "Question" before you ask your question. Believe me I'll know.

    That said, I would have said this first if it had to precede what I'm telling you now. Having said that, what I'm telling you now is the same thing I just said about the annoying phrases "That said" and "Having said that".


    Are you threatening me, Master Jedi?
    -Chancellor Palpatine

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: return(*var=0,NULL);

    I believe you are correct.

    In C++, the comma operator evaluates each expression from left to right, and the value of the expression is the last operand.

    For example,

    Code:
    int a, b;
    b = (a = 3, a++, a + 7)
    assigns b the value of 11.

    I'm not sure why the code would be written that way, except to keep it all on a single line. It would be better to write it as you did:

    Code:
    if (somthing == NULL)
    {
         *count = 0;
         return NULL;
    }
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3

    Thread Starter
    Addicted Member Phenix's Avatar
    Join Date
    Sep 2002
    Location
    Near A Cube
    Posts
    228

    [RESOLVED] Re: return(*var=0,NULL);

    Thanks.
    Circa 1995
    Engineer - I think we should put our website address on our paper catalogs.
    Vice President - Don't get too excited about this internet thing.


    I am sorry, but the Oracle was mistaken. You cannot help us.
    -Matrix video game


    I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. ... and it probably never will support anything other than AT-harddisks, as that's all I have :-(.
    -Linus


    Question. Do you know that the character "?" means I'm asking a question? Question. Do you know that spoken inflection also provides the same cue? So please don't say, "Question" before you ask your question. Believe me I'll know.

    That said, I would have said this first if it had to precede what I'm telling you now. Having said that, what I'm telling you now is the same thing I just said about the annoying phrases "That said" and "Having said that".


    Are you threatening me, Master Jedi?
    -Chancellor Palpatine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width