-1

Please tell me, where can I find the wchar_t declaration. I use linux, and I think it is 32 bits. I need to declarate this type, because i can't use the standart library (it is used in my boot programm). The files /usr/include/wchar.h and /usr/include/linux/stddef.h don't contain the declaration of it. Also what about mbstate_t?

Maxim Gusev
  • 213
  • 3
  • 10

2 Answers2

0

You don't need to go to the files containing the definition of wchar_t.
In the standard header stdint.h it can be found the information about integer types in your particular implementation.

For example, the constants WCHAR_MIN and WCHAR_MAX bring information about the range of values of wchar_t.

On the ohter hand, if WCHAR_MIN == 0, then wchar_t is an unsigned integer type. Else, it's a signed integer type (in this case it would prefirable to check the condition WCHAR_MIN < 0).

To know the amount of bytes used to represent a wchar_t object, you have, of course, the expression sizeof(wchar_t).

pablo1977
  • 4,281
  • 1
  • 15
  • 41
0

If you are not using the standard library, then you do not need wchar_t. Or at least the standard library's idea of wchar_t doesn't matter to you. How could it? If you want wide character handling then you'll need to write whatever functions are needed for it, and you are free to define and use whatever types are most suitable / convenient for that purpose.

You probably will need the kernel headers, though, if you intend make system calls. I can't imagine how your boot program could avoid that, or why it would want to do. Those types you would need for that purpose will be defined among the kernel headers. You will not need kernel headers, either: since the point of your program is to load and start the kernel, it cannot rely on system calls into the kernel to do its job.

The bottom line is that since you have to provide everything not available directly from the hardware / firmware -- which does not present a C interface -- no C definitions outside your own code are relevant to you. In particular, wchar_t is not a characteristic of any system; rather, it is a characteristic of a particular C library. Different C libraries for the very same system, including yours, can freely define it differently. If you choose to implement your own wide-character functions, there is no advantage whatever to choosing a wchar_t definition drawn from some other C library.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • I don't think you can make system calls in a boot program. BIOS calls are possible, but there aren't any header files for these. – fuz Sep 16 '15 at 15:47
  • Yes. System calls are not available. I'm writing a boot code and use some standart library functions (I'll implement them). – Maxim Gusev Sep 16 '15 at 16:09