Share this page

# typedef

Creates a Storage-Class Specifier for a custom type composed of standard C-language types or other types created with typedef.

## Example

The following example uses a typedef, about_app_t, to a structure called about_app. Using a typedef simplifies all future references to the structure (for example, in the call to the memset function) because there is no need to specify the full identifier "struct about_app".

An instance of this structure, a, is defined and used in the function Actions.

Copy code

        typedef struct about_app {
            char * version;
            int field1;
            int field2;
        } about_app_t;
        about_app_t a; // Global scope
        a.field1 = 12;
        a.field2 = 13;
    //Set all fields to 0
        memset(&a, 0, sizeof(about_app_t));
        // Show that fields have a value of 0
        lr_output_message ("After memset field1=%d field2=%d", a.field1, a.field2);
        a.version = "app version 1.0";
        a.field1 = 5;
        a.field2 = 6;
        lr_output_message ("Now, field1=%d field2=%d", a.field1, a.field2);

    Example: Output:
    Action.c(18): After memset field1=0 field2=0
    Action.c(23): Now, field1=5 field2=6

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: