Mentions légales du service

Skip to content

Valid C++ code (albeit C-inspired) doesn't work

Following code:

struct VectorAndInstantiate
{
    double x;
    double y;
    double z;    
} v1; // Here the struct is declared and at the same time an object v1 is created

v1.x = 1.;
v1.y = 5.;
v1.z = -2.;

doesn't work.

It is in fact very likely related to cling itself: in Xeus-cling it stopped working circa 2022, and the error message itself points out cling internals:

input_line_22:8:2: error: expected ';' after struct
} void __cling_Un1Qu33(void* vpClingValue) {
 ^
 ;
input_line_22:9:2: error: use of undeclared identifier 'v1'
 v1; // Here the struct is declared and at the same time an object v1 is created
 ^
input_line_22:11:1: error: use of undeclared identifier 'v1'
v1.x = 1.;
^
input_line_22:12:1: error: use of undeclared identifier 'v1'
v1.y = 5.;
^
input_line_22:13:1: error: use of undeclared identifier 'v1'
v1.z = -2.;
^
Edited by GILLES Sebastien
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information