Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camlidl: some "const" quirks #3205

Closed
vicuna opened this issue Feb 14, 2002 · 1 comment
Closed

camlidl: some "const" quirks #3205

vicuna opened this issue Feb 14, 2002 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Feb 14, 2002

Original bug ID: 892
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues

Bug description

typedef [ref,string] char* String;
void f1(const String s); // OK
const String f2(); // line 3, column 15: syntax error

"const" is accepted in paramater definition, but not in the returned type
one. Is this intentional?

typedef [ref,string] char* String;
void f1(const String s);

produces a .c file that compiles with warnings:

...
void camlidl_ml2c_const2_String(value _v1, String * _c2, camlidl_ctx _ctx)
{
(_c2) = camlidl_malloc_string(_v1, _ctx);
}
...
value camlidl_const2_f1(
value _v_s)
{
/

We will fill "s" later so it should not be const!
/
String const s; /in/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
/

const2.c
const2.c(36) : warning C4090: 'function' : different 'const' qualifiers
const2.c(36) : warning C4024: 'camlidl_ml2c_const2_String' :
different types for formal and actual parameter 2
*/
camlidl_ml2c_const2_String(_v_s, &s, _ctx);
f1(s);
camlidl_free(_ctx);
return Val_unit;
}

It may even lead to error (not warning) as in the following case (it makes
not much sense, just demonstrates the problem):

IDL:
void f(const int i);
|
V
C:
value camlidl_const3_f(
value _v_i)
{
int const i; /in/
/*
const3.c
const3.c(22) : error C2166: l-value specifies const object
*/
i = Int_val(_v_i);
f(i);
return Val_unit;
}

Not that I cannot live with it, but ...

Hope to hear from you soon,
Dmitry

@vicuna
Copy link
Author

vicuna commented Apr 22, 2002

Comment author: administrator

Problem 1: ambiguity in Yacc grammar, no solution yet. Problem 2: strip const
qualifiers on local variables (2002-04-22, XL).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant