Thread: some codes need explnation

  1. #1
    Registered User
    Join Date
    May 2020
    Posts
    6

    Question some codes need explnation

    hello everyone,

    I have the following code:

    Code:
    typedef struct Y {
        unsigned char *head;
        unsigned char *tail;
        unsigned char *data;
    } X;
    
    struct mme_ue_t {
        ogs_lnode_t  lnode;       /*a variable from ogs_lnode_t structer which defined with typdef*/
        ogs_fsm_t    sm;          /*a variable from ogs_fsm_t structer which defined with typdef*/
    };
    
    X *sgsap_build(mme_ue_t *mme_ue);
    the question is: what's the meaning of the last Line and how has executed? does that mean that sgsap_build acts as a function

    X *sgsap_build(mme_ue_t *mme_ue);

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,922
    It is a declaration of a function named sgsap_build that takes a pointer to mme_ue_t as an argument and returns a pointer to X.

    Note that you should have a typedef of struct mme_ue_t to mme_ue_t.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2020
    Posts
    6
    many thanks dear ..
    please could you explain more about your note, why I should using a typedef in this case?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,922
    Why don't you write a tiny example program and try to compile it?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    May 2020
    Posts
    6
    I just mean that I need the theoretical concept of your note.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,922
    You declared struct mme_ue_t, so you can only use struct mme_ue_t, not mme_ue_t. You need a typedef to use mme_ue_t.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 07-31-2017, 10:14 AM
  2. Validate area codes within a list of area codes
    By Staja24 in forum C Programming
    Replies: 9
    Last Post: 05-06-2015, 09:28 PM
  3. how to add codes ?
    By zcrself in forum C Programming
    Replies: 2
    Last Post: 08-23-2010, 01:33 AM
  4. mp3 codes
    By vhf in forum C++ Programming
    Replies: 2
    Last Post: 03-26-2002, 12:34 PM
  5. converting scan codes to ascii codes
    By stupid_mutt in forum C Programming
    Replies: 11
    Last Post: 01-25-2002, 04:06 PM

Tags for this Thread