What does this string(the a modifier in a macro)?

0 like 0 dislike
7 views
Hello! Please explain how this modifier MYLIBAPI will affect function?

#define MYLIBAPI extern "C" __declspec(dllimport)
by | 7 views

3 Answers

0 like 0 dislike
The macro simplifies the import of the dll into the program. Where will use "MYLIBAPI", will unfold the Directive import of the dll.
extern "C" denotes the use of a simple generating function signature (in the style of the language C) receive object files. In particular, this prevents the C++ compiler to produce the "scenery" (or "decoration") function name additional symbols when working with DLL
Example:
extern "C" __declspec(dllimport)double AddNumbers(double a, double b);
in your case you can write
MYLIBAPI double AddNumbers(double a, double b);
by
0 like 0 dislike
There are two modifier.

1. extern "C" says that the function is NOT necessary "kazaviti" in the manner of C++ coding in behalf of its parameters like h(int) → _Z1hi. Is used to access C++ functions that are compiled with another compiler (Pascal, C,...) and also for all sorts of functions, we need to give a fixed name, for example, DLL functions.

2. __declspec(dllimport). It is necessary to access the DLL functions: the linker will take the functions directly from the DLL without creating it *.lib or *.a (at least MinGW works). Languages, strongly attached to a specific OS (e.g., Delphi) can create your keywords to access, for example, DLL or COM.
procedure DoSomething(x : integer); cdecl; external 'something.dll';

Destandartization si forced to rely upon keywords that start with two underscores.
by
0 like 0 dislike
It's not a modifier. This is the name of the macro. And then - his body. Now everywhere in your code MYLIBAPI will be replaced by the body.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
5 answers
0 like 0 dislike
1 answer
asked Apr 25, 2019 by kapitoly
110,608 questions
257,186 answers
0 comments
33,912 users