I
Immortal_Nephi
You have written several global functions inside header code. Then,
you create either static library or dynamic linked library. All
global functions can be reuseable to the main() function when you
include header code.
One problem is that you have created one function. You want to place
it in the main's source code. You may not want to move it back to the
header code. The C++ Compiler will compile and link without any
problems if one function is defined outside of header code.
For example:
// Func.h header
void ReadWrite(); // function phototype
void Func1() {}
void Func2() {}
void Func3() {}
void Run()
{
Func1();
Func2();
Func3();
ReadWrite();
}
// main.cpp source code
#include "Func.h"
void ReadWrite() // define ReadWrite() here
{
}
int main()
{
Run();
return 0;
}
You can see what I mean. Func1(), Func2(),Func3(), and Run() are
always unmodified in the .lib or .dll. You want to modify ReadWrte()
in main.cpp source code.
If you forget to define ReadWrite(), then C++ Compiler succeeds to
compile, but it fails to link. The pointer to function is only the
option. You should bind ReadWrite() where Run() can executes
ReadWrite().
If you forget to define pointer to function, then C++ Compiler
succeeds to compile and link before executing program can crash with
null of pointer to function.
Please suggest the best practice how .lib and .dll can call
ReadWrite() in main.cpp source code.
Nephi
you create either static library or dynamic linked library. All
global functions can be reuseable to the main() function when you
include header code.
One problem is that you have created one function. You want to place
it in the main's source code. You may not want to move it back to the
header code. The C++ Compiler will compile and link without any
problems if one function is defined outside of header code.
For example:
// Func.h header
void ReadWrite(); // function phototype
void Func1() {}
void Func2() {}
void Func3() {}
void Run()
{
Func1();
Func2();
Func3();
ReadWrite();
}
// main.cpp source code
#include "Func.h"
void ReadWrite() // define ReadWrite() here
{
}
int main()
{
Run();
return 0;
}
You can see what I mean. Func1(), Func2(),Func3(), and Run() are
always unmodified in the .lib or .dll. You want to modify ReadWrte()
in main.cpp source code.
If you forget to define ReadWrite(), then C++ Compiler succeeds to
compile, but it fails to link. The pointer to function is only the
option. You should bind ReadWrite() where Run() can executes
ReadWrite().
If you forget to define pointer to function, then C++ Compiler
succeeds to compile and link before executing program can crash with
null of pointer to function.
Please suggest the best practice how .lib and .dll can call
ReadWrite() in main.cpp source code.
Nephi