I'm trying to compile the example from https://www.ginac.de/tutorial/#Input_002foutput.

My complete version of the example, with 'include' and 'using' statements, and with an added declaration of x and y in main(), is:

-----
#include <iostream>
#include <ginac/ginac.h>

using namespace std;
using namespace GiNaC;


static void my_print(const ex & e)
{
    if (is_a<function>(e))
        cout << ex_to<function>(e).get_name();
    else
        cout << ex_to<basic>(e).class_name();
    cout << "(";
    size_t n = e.nops();
    if (n)
        for (size_t i=0; i<n; i++) {
            my_print(e.op(i));
            if (i != n-1)
                cout << ",";
        }
    else
        cout << e;
    cout << ")";
}

int main()
{
    symbol x("x"), y("y");
    my_print(pow(3, x) - 2 * sin(y / Pi));
    cout << endl;
    return 0;
}

-----

I compile it with

$ g++ --std=c++17 $(pkg-config --cflags ginac cln) custom_expression_output.cpp $(pkg-config --libs ginac cln) -o custom_expression_output

which gives the following, with either g++ 11.4.0 or 12.3.0:

-----
custom_expression_output.cpp: In function ‘void my_print(const GiNaC::ex&)’:
custom_expression_output.cpp:16:9: error: parse error in template argument list
   16 |     if (is_a<function>(e))
      |         ^~~~~~~~~~~~~~
custom_expression_output.cpp:16:23: error: no matching function for call to ‘is_a<<expression error> >(const GiNaC::ex&)’
   16 |     if (is_a<function>(e))
      |         ~~~~~~~~~~~~~~^~~
In file included from /home/warren/local/include/ginac/registrar.h:27,
                 from /home/warren/local/include/ginac/basic.h:29,
                 from /home/warren/local/include/ginac/ginac.h:28,
                 from custom_expression_output.cpp:8:
/home/warren/local/include/ginac/print.h:189:13: note: candidate: ‘template<class T> bool GiNaC::is_a(const GiNaC::print_context&)’
  189 | inline bool is_a(const print_context & obj)
      |             ^~~~
/home/warren/local/include/ginac/print.h:189:13: note:   template argument deduction/substitution failed:
custom_expression_output.cpp:16:23: error: template argument 1 is invalid
   16 |     if (is_a<function>(e))
      |         ~~~~~~~~~~~~~~^~~
In file included from /home/warren/local/include/ginac/ginac.h:28,
                 from custom_expression_output.cpp:8:
/home/warren/local/include/ginac/basic.h:313:13: note: candidate: ‘template<class T> bool GiNaC::is_a(const GiNaC::basic&)’
  313 | inline bool is_a(const basic &obj)
      |             ^~~~
/home/warren/local/include/ginac/basic.h:313:13: note:   template argument deduction/substitution failed:
custom_expression_output.cpp:16:23: error: template argument 1 is invalid
   16 |     if (is_a<function>(e))
      |         ~~~~~~~~~~~~~~^~~
In file included from /home/warren/local/include/ginac/ginac.h:30,
                 from custom_expression_output.cpp:8:
/home/warren/local/include/ginac/ex.h:955:13: note: candidate: ‘template<class T> bool GiNaC::is_a(const GiNaC::ex&)’
  955 | inline bool is_a(const ex &obj)
      |             ^~~~
/home/warren/local/include/ginac/ex.h:955:13: note:   template argument deduction/substitution failed:
custom_expression_output.cpp:16:23: error: template argument 1 is invalid
   16 |     if (is_a<function>(e))
      |         ~~~~~~~~~~~~~~^~~
custom_expression_output.cpp:17:17: error: parse error in template argument list
   17 |         cout << ex_to<function>(e).get_name();
      |                 ^~~~~~~~~~~~~~~
custom_expression_output.cpp:17:32: error: no matching function for call to ‘ex_to<<expression error> >(const GiNaC::ex&)’
   17 |         cout << ex_to<function>(e).get_name();
      |                 ~~~~~~~~~~~~~~~^~~
In file included from /home/warren/local/include/ginac/ginac.h:30,
                 from custom_expression_output.cpp:8:
/home/warren/local/include/ginac/ex.h:978:17: note: candidate: ‘template<class T> const T& GiNaC::ex_to(const GiNaC::ex&)’
  978 | inline const T &ex_to(const ex &e)
      |                 ^~~~~
/home/warren/local/include/ginac/ex.h:978:17: note:   template argument deduction/substitution failed:
custom_expression_output.cpp:17:32: error: template argument 1 is invalid
   17 |         cout << ex_to<function>(e).get_name();
      |                 ~~~~~~~~~~~~~~~^~~
-----

If I change the first occurrence of "function" to "symbol" (just to see how it compiles), the expression is_a<symbol>(e) does not result in an error (but the compilation fails for other reasons).

Any ideas of what is going on?

Warren