Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>afaik, you'll need to bake that info into your binary. just create a function which returns the sizeof and alignof in a struct, supports the types you must support, then call that function (or class method) for the info.</p> <p>The program below shows you that many of the primitives are just one character. So the bulk of the function's implementation could be a switch.</p> <pre><code>static void test(SEL sel) { Method method = class_getInstanceMethod([NSString class], sel); const char* const type = method_copyReturnType(method); printf("%s : %s\n", NSStringFromSelector(sel).UTF8String, type); free((void*)type); } int main(int argc, char *argv[]) { @autoreleasepool { test(@selector(init)); test(@selector(superclass)); test(@selector(isEqual:)); test(@selector(length)); return 0; } } </code></pre> <p>and you could then use this as a starting point:</p> <pre><code>typedef struct t_pair_alignof_sizeof { size_t align; size_t size; } t_pair_alignof_sizeof; static t_pair_alignof_sizeof MakeAlignOfSizeOf(size_t align, size_t size) { t_pair_alignof_sizeof ret = {align, size}; return ret; } static t_pair_alignof_sizeof test2(SEL sel) { Method method = class_getInstanceMethod([NSString class], sel); const char* const type = method_copyReturnType(method); const size_t length = strlen(type); if (1U == length) { switch (type[0]) { case '@' : return MakeAlignOfSizeOf(__alignof__(id), sizeof(id)); case '#' : return MakeAlignOfSizeOf(__alignof__(Class), sizeof(Class)); case 'c' : return MakeAlignOfSizeOf(__alignof__(signed char), sizeof(signed char)); ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload