1

I try to compile C++ Mathematical Expression Library (http://www.partow.net/programming/exprtk/index.html) by Arash Parto. Unfort. I do not succeed using 10.2. erf, erff, etc. are not found.

File try to compile:

#pragma hdrstop
#pragma argsused

#ifdef _WIN32
#include <tchar.h>
#else
  typedef char _TCHAR;
  #define _tmain main
#endif

#include <stdio.h>

#include <cmath>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#include "exprtk.hpp"


#ifdef exprtk_test_float32_type
typedef float numeric_type;
#else
typedef double numeric_type;
#endif

some defs...

int _tmain(int argc, _TCHAR* argv[])
{
   #define perform_test(Type,Number)                                               
   int result = 0;

   perform_test(numeric_type,00)

   #undef perform_test

   return result;
}

=======================================

Error log:

Project "D:_Entwicklung.KEL\exprtk_new\Project2.cbproj" (Build target(s)):

Target CreateProjectDirectories:
Creating directory ".\Win32\Debug".
Compiling C++ files...
Target MakeObjs:
Target TCCompile:
C:\Program Files (x86)\JomiTech\TwineCompile\mtbcc32.exe -ide102 -priority0 -files="D:_Entwicklung.KEL\exprtk_new\twfiles.@@@"
JomiTech TwineCompile 4.5 - Copyright JomiTech 2016. All Rights Reserved.
Compiling 1 files...
Embarcadero C++ 7.30 for Win32 Copyright (c) 1993-2017 Embarcadero Technologies, Inc.
d:_Entwicklung.KEL\exprtk_new\File2.cpp
File2.cpp: (0) 0 of 0
File2.cpp: (0) 368546 of 368546
d:_Entwicklung.KEL\exprtk_new\exprtk.hpp(1200,49): C++ error E2268: Call to undefined function 'erff'

After Remy Lebau's advice I tried the following

@RemyLebeau: Thanks for your advice. However I feel so useless.....

I tried (of course no **):

    **using namespace std;**
    #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER)
    #define exprtk_define_erf(TT,impl)           \
    inline TT erf_impl(TT v) { return impl(v); } \

    exprtk_define_erf(      float,::erff)
    exprtk_define_erf(     double,::erf )
    exprtk_define_erf(long double,::erfl)
    #undef exprtk_define_erf
    #endif

==> [bcc32c Error] exprtk.hpp(1199): no member named 'erff' in the global namespace

Then I tried:

    #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER)
    #define exprtk_define_erf(TT,impl)           \
    inline TT erf_impl(TT v) { return impl(v); } \

    exprtk_define_erf(      float,**std**::erff)
    exprtk_define_erf(     double,**std**::erf )
    exprtk_define_erf(long double,**std**::erfl)
    #undef exprtk_define_erf
    #endif

==> [bcc32c Error] exprtk.hpp(1198): no member named 'erff' in namespace 'std'

New file2.cpp

#pragma hdrstop
#pragma argsused

#ifdef _WIN32
#include <tchar.h>
#else
  typedef char _TCHAR;
  #define _tmain main
#endif

using namespace std;
#include "exprtk.hpp"

template <typename T>
void trig_function()
{
   typedef exprtk::symbol_table<T> symbol_table_t;
   typedef exprtk::expression<T>     expression_t;
   typedef exprtk::parser<T>             parser_t;
//
   const std::string expression_string =
                     "clamp(-1.0,sin(2 * pi * x) + cos(x / 2 * pi),+1.0)";

   T x;

   symbol_table_t symbol_table;
   symbol_table.add_variable("x",x);
   symbol_table.add_constants();

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   parser_t parser;
   parser.compile(expression_string,expression);
//
   for (x = T(-5); x <= T(+5); x += T(0.001))
   {
      const T y = expression.value();
      printf("%19.15f\t%19.15f\n", x, y);
   }
}

int _tmain(int argc, _TCHAR* argv[])
{

   trig_function<double>();
   int result = 0;

   return result;
}

After modifiying in #include "exprtk.hpp":

           #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER)
            #define exprtk_define_erf(TT,impl)           \
            inline TT erf_impl(TT v) { return impl(v); } \

//            exprtk_define_erf(      float,::erff)
            exprtk_define_erf(     double,::erf )
//            exprtk_define_erf(long double,::erfl)
            #undef exprtk_define_erf
            #endif

I get now: [ilink32 Error] Fatal: Exceeded memory limit for block Publics in module File2.cpp

aekeller
  • 11
  • 3
  • Isn't it possible to add the code to produce the error? (if the code is too big to paste directly, you may also need to simplify the question.) – ITO Yosei Sep 17 '20 at 12:54
  • How can I upload a zip-file with the project in it? – aekeller Sep 17 '20 at 15:43
  • @aekeller Attachments are not allowed here. Please [edit] your question to provide a [mcve] showing the minimum code needed to reproduce the error. – Remy Lebeau Sep 17 '20 at 16:51
  • 1
    `erf`, `erff`, etc are C++11 math functions defined in ``. So, make sure the code in question has `#include `, and also that you are compiling the project with one of Embarcadero's [clang-based compilers](http://docwiki.embarcadero.com/RADStudio/en/Clang-enhanced_C%2B%2B_Compilers) that support C++11, not with the "classic" Borland compiler which doesn't. From the command-line shown, you are using TwineCompile, I don't know which of Embarcadero's compilers it invokes internally. – Remy Lebeau Sep 17 '20 at 16:55
  • I switches off now TwineCompile, as well I do not use the "classic" Borland compiler anymore.... Get now: [bcc32c Error] exprtk.hpp(1200): no member named 'erff' in the global namespace – aekeller Sep 17 '20 at 17:16
  • `exprtk.hpp` refers to `erff()` as `::erff`, but `` defines `erff()` in the `std` namespace, not in the global namespace. You could try adding `using namespace std;` or better `using std::erff;` to bring `std::erff()` into the global namespace. Or simply change the offending code to use `std::erff` instead of `::erff`. Same with `erf` and `erfl`. Or, if you really want to be fancy, `exprtk.hpp` uses `::erff` inside of a `exprtk_define_erf()` macro, so define a different version of that macro for Embarcadero's compiler that prefixes `::erff` with `std`. – Remy Lebeau Sep 18 '20 at 00:01
  • @RemyLebeau: Thanks for your advice. However I feel so useless.... I tried to go after your advices ==> See my description in above. I still get **[bcc32c Error] exprtk.hpp(1198): no member named 'erff' in namespace 'std'** even using **using namespace std;** or using **exprtk_define_erf( float,std::erff)**. – aekeller Sep 18 '20 at 06:50
  • I am one step further. I commented erff and erfl // exprtk_define_erf( float,::erff) exprtk_define_erf( double,::erf ) // exprtk_define_erf(long double,::erfl) Now it compiles, but does not link: [ilink32 Error] Fatal: Exceeded memory limit for block Publics in module File2.cpp My modiefied file2.cpp you can find above – aekeller Sep 18 '20 at 08:30

0 Answers0