# Special C++ api?

**URL:** https://scilab.discourse.group/t/special-c-api/645
**Category:** Dynamic link
**Created:** [September 17, 2024, 3:00pm UTC](https://scilab.discourse.group/t/special-c-api/645 "2024-09-17T15:00:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![esch](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@esch](https://scilab.discourse.group/u/esch)
#### Post date: [September 17, 2024, 3:00pm UTC](https://scilab.discourse.group/t/special-c-api/645/1 "2024-09-17T15:00:03Z")

</div>

Hello,

The help chapter “Getting started with API\_Scilab” gives us an example based on the api\_scilab.h header file.  
I saw that there exist in the folder Scilab\contrib\toolbox\_skeleton\sci\_gateway\cpp another API for C++. Is this API official and will it be maintained in the futur ?

---

<div class="post-metadata">

### Author: ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)
#### Post date: [September 17, 2024, 3:45pm UTC](https://scilab.discourse.group/t/special-c-api/645/2 "2024-09-17T15:45:57Z")

</div>

Hello, welcome there !

> [@esch](#):
>
> Is this API official

What I can say is that it is the de facto standard, as all older gateways APIs are wrappers on this new C++ API. In all my contributions (in Scilab itself, or in toolboxes, such as sci\_ipopt), I have exclusively used this API. Maybe someone else (@vincent.couvert) can say why we don’t promote it ?

S.

---

<div class="post-metadata">

### Author: ![esch](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@esch](https://scilab.discourse.group/u/esch)
#### Post date: [September 17, 2024, 4:12pm UTC](https://scilab.discourse.group/t/special-c-api/645/3 "2024-09-17T16:12:04Z")

</div>

Hello mottelet,

You convinced me to use this C++ API in the futur.  
Thank you for your answer and for all the work you do for the community !

ES

---

<div class="post-metadata">

### Author: ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)
#### Post date: [September 18, 2024, 9:41am UTC](https://scilab.discourse.group/t/special-c-api/645/4 "2024-09-18T09:41:03Z")

</div>

Here is an example:

```scilab
code=[
"#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 "
"#include <cmath> "
"#include ""double.hxx"" "
"#include ""function.hxx"" "
"extern ""C"" "
"{ "
"#include ""Scierror.h"" "
"#include ""localization.h"" "
"} "
"/* ==================================================================== */ "
"types::Function::ReturnValue sci_zeta(types::typed_list &in, int _iRetCount, types::typed_list &out) "
"{ "
" types::Double* pDblOut; "
" types::Double* pDblIn; "
" if (in.size() != 1) "
" { "
" Scierror(77, _(""%s: Wrong number of input argument(s): %d expected.\n""), ""zeta"", 1); "
" return types::Function::Error; "
" } "
" if (_iRetCount > 1) "
" { "
" Scierror(78, _(""%s: Wrong number of output argument(s): %d expected.""), ""zeta"", 1); "
" return types::Function::Error; "
" } "
" if (in[0]->isDouble() == false || in[0]->getAs<types::Double>()->isComplex()) "
" { "
" Scierror(999, _(""%s: Wrong type for input argument #%d: real expected.\n""), ""zeta"", 1); "
" return types::Function::Error; "
" } "
" pDblIn = in[0]->getAs<types::Double>(); "
" pDblOut = pDblIn->clone(); "
" for (int i = 0 ; i < pDblIn->getSize() ; ++i) "
" { "
" pDblOut->set(i,std::riemann_zeta(pDblIn->get(i))); "
" } "
" out.push_back(pDblOut); "
" return types::Function::OK; "
"} "
];
ulink
files = fullfile(TMPDIR,"sci_zeta.cpp");
mputl(code,files)
ilib_verbose(2)
ilib_build("zeta", ["zeta" "sci_zeta" "cppsci"],files,[])
exec loader.sce

tic
disp(zeta(0.5))
disp(toc())

```
