# add\_struc\_member

Add structure member.

This function can be used in two forms. First form: long add\_struc\_member(long id, string name, long offset, long flag, long typeid, long nbytes); Second form: long add\_struc\_member(long id, string name, long offset, long flag, long typeid, long nbytes, long target, long tdelta, long reftype);

arguments: id - structure type ID name - name of the new member offset - offset of the new member -1 means to add at the end of the structure flag - type of the new member. Should be one of FF\_BYTE..FF\_PACKREAL (see above) combined with FF\_DATA typeid - if is\_struct(flag) then typeid specifies the structure id for the member if is\_off0(flag) then typeid specifies the offset base. if is\_strlit(flag) then typeid specifies the string type ([STRTYPE\_...](/8.4/developer-guide/idc/idc-api-reference/alphabetical-list-of-idc-functions/283.md)). if is\_stroff(flag) then typeid specifies the structure id if is\_enum(flag) then typeid specifies the enum id Otherwise typeid should be -1 nbytes - number of bytes in the new member the remaining arguments are allowed only if isOff0(flag) and you want to specify a complex offset expression target - target address of the offset expr. You may specify it as -1, ida will calculate it itself tdelta - offset target delta. usually 0 reftype - see REF\_... definitions returns: 0 - ok, otherwise error code STRUC\_ERROR\_...

long add\_struc\_member(long id, string name, long offset, long flag, long typeid, long nbytes, long target, long tdelta, long reftype);

// Constants used with begin\_type\_updating() and end\_type\_updating() #define UTP\_ENUM 0 #define UTP\_STRUCT 1

\#define STRUC\_ERROR\_MEMBER\_NAME (-1) // already has member with this name (bad name) #define STRUC\_ERROR\_MEMBER\_OFFSET (-2) // already has member at this offset #define STRUC\_ERROR\_MEMBER\_SIZE (-3) // bad number of bytes or bad sizeof(type) #define STRUC\_ERROR\_MEMBER\_TINFO (-4) // bad typeid parameter #define STRUC\_ERROR\_MEMBER\_STRUCT (-5) // bad struct id (the 1st argument) #define STRUC\_ERROR\_MEMBER\_UNIVAR (-6) // unions can't have variable sized members #define STRUC\_ERROR\_MEMBER\_VARLAST (-7) // variable sized member should be the last member in the structure #define STRUC\_ERROR\_MEMBER\_NESTED (-8) // recursive structure nesting is forbidden


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hex-rays.com/8.4/developer-guide/idc/idc-api-reference/alphabetical-list-of-idc-functions/398.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
