Skip to content

Commit

Permalink
Fix external function call
Browse files Browse the repository at this point in the history
  • Loading branch information
beutlich committed Oct 12, 2021
1 parent 547d8c9 commit 7468cae
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions chapters/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,7 @@ \subsection{Annotations for External Libraries and Include Files}\label{annotati
der(x) = -ExternalFunc3(x);
end OtherExample;

function ExternalFunc1
function ExternalFunc1 "Include header file for library implementation"
input Real x;
output Real y;
external "C"
Expand All @@ -2418,18 +2418,18 @@ \subsection{Annotations for External Libraries and Include Files}\label{annotati
Include = "#include \"ExternalFunc1.h\"",
SourceDirectory =
"modelica://ExternalFunctions/Resources/Source");
// The SourceDirectory is the default and thus redundant.
// The specified SourceDirectory is the default and thus redundant.
end ExternalFunc1;

function ExternalFunc2
function ExternalFunc2 "Include header file for library implementation"
input Real x;
output Real y;
external "C"
annotation(Library = "ExternalLib2",
Include = "#include \"ExternalFunc2.h\"");
end ExternalFunc2;

function ExternalFunc3
function ExternalFunc3 "Include source file"
input Real x;
output Real y;
external "C"
Expand Down Expand Up @@ -2472,7 +2472,7 @@ \subsection{Annotations for External Libraries and Include Files}\label{annotati
The C-source \filename{ExternalFunc3.c} will be included fully, and is not part of any library.
That is not ideal for C-code, but it works for small functions.

It is not specified how the C-sources in \filename{Source} will be used to build the libraries.
It is not specified how the C-sources in the specified \lstinline!SourceDirectory! will be used to build the libraries.

Header file for the function in the dynamic link / shared library
\filename{ExternalLib2} so that the desired functions are defined to be exported
Expand All @@ -2481,7 +2481,9 @@ \subsection{Annotations for External Libraries and Include Files}\label{annotati
libraries or object libraries that are later transformed to a shared
library):
\begin{lstlisting}[language=C]
// File ExternalFunc2.h
/* File ExternalFunc2.h */
#ifndef EXTERNAL_FUNC2_H_
#define EXTERNAL_FUNC2_H_
#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -2499,11 +2501,12 @@ \subsection{Annotations for External Libraries and Include Files}\label{annotati
# define EXTLIB2_EXPORT
#endif

EXTLIB2_EXPORT void ExternalFunc2(<function arguments>);
EXTLIB2_EXPORT double ExternalFunc2(double);

#ifdef __cplusplus
}
#endif
#endif
\end{lstlisting}
\end{example}

Expand Down

0 comments on commit 7468cae

Please sign in to comment.