You copied the Doc URL to your clipboard.

-fshort-wchar, -fno-short-wchar

Sets the size of wchar_t to 2 bytes.

The -fshort-wchar option can improve memory usage, but might reduce performance because narrow memory accesses can be less efficient than full register-width accesses.

Note

All linked objects must use the same wchar_t size, including libraries. It is not possible to link an object file compiled with -fshort-wchar, with another object file that is compiled without -fshort-wchar.

Default

The default is -fno-short-wchar. That is. the default size of wchar_t is 4 bytes.

Example

This example shows the size of the wchar_t type:

#include <stdio.h>
#include <wchar.h>

int main(void)
{
  printf("size of wchar_t is %zd\n", sizeof (wchar_t));
  return 0;
}

When compiled without the -fshort-wchar option, the size of wchar_t is 4 bytes:

armclang --target=aarch64-arm-none-eabi wchar_test.c
                
size of wchar_t is 4

When compiled with the -fshort-wchar option, the size of wchar_t is 2 bytes:

armclang -fshort-wchar --target=aarch64-arm-none-eabi wchar_test.c
                
size of wchar_t is 2
Was this page helpful? Yes No