0

I'm learning UEFI programming and I notice that many of the EFI header files show chunks with this syntax I can't understand:

typedef
EFI_STATUS
(EFIAPI *EFI_TEXT_STRING) (
    IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
    IN CHAR16 *String
);
  • Could you please explain what are the arguments of that typedef in this case?
  • How come those IN's are legal syntax? Is it a compiler specific feature?
pr0gma
  • 577
  • 3
  • 8
  • 18
  • Possible duplicate of [Understanding typedefs for function pointers in C](http://stackoverflow.com/questions/1591361/understanding-typedefs-for-function-pointers-in-c) – Ivan Aksamentov - Drop Aug 23 '16 at 09:16
  • 1
    Please ask only one question per question in the future. – Ivan Aksamentov - Drop Aug 23 '16 at 09:17
  • you can first go through macros and see how they are effectively used. This will help you understand this little faster. – Sridhar Nagarajan Aug 23 '16 at 09:18
  • `IN` is most likely the macro, which is most likely expands to `const` – Ivan Aksamentov - Drop Aug 23 '16 at 09:18
  • looking at [this source code](http://www.virtualbox.org/svn/vbox/trunk/src/VBox/Devices/PC/ipxe/src/include/ipxe/efi/Base.h) `IN` and `OUT` are empty defines used as "comment" of struct members – LPs Aug 23 '16 at 09:20
  • `gcc -E ...` will expand the macros for you – pmg Aug 23 '16 at 09:20
  • @pmg I tried both gcc -E and a "raw" cpp, but 'IN' is still there.Since the two question refer to the same block and, as far as I knew when I wrote the question, could be related, I don't see how posting the same code in two different question could be of any use. Is this the reason for the downvote? – pr0gma Aug 23 '16 at 10:37
  • Did you look at the link in my comment? – LPs Aug 23 '16 at 12:09
  • 1
    @LPs Yes I did, and I've finally found the preprocessor directives which define IN, OUT and OPTIONAL (they happen to be in efidef.h). – pr0gma Aug 23 '16 at 12:26

1 Answers1

1

It is a simple typdef for a function pointer. Type EFI_TEXT_STRING is a pointer to a function that takes a pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL as its first argument and a pointer to CHAR16 as its second argument. The function returns type EFI_STATUS.

ReluctantBIOSGuy
  • 536
  • 2
  • 12