v icon indicating copy to clipboard operation
v copied to clipboard

C error: function pointer expected

Open einar-hjortdal opened this issue 1 year ago • 9 comments

Describe the bug

C error: function pointer expected

Reproduction Steps

git clone [email protected]:einar-hjortdal/firebird.git \
&& cd firebird \
&& git checkout ecba31c3cb1a56e80f49599cdee14131547ded38 \
&& v run src/secure_remote_password_test.v

Expected Behavior

No C error

Current Behavior

C error

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.7 263ba23

Environment details (OS name and version, etc.)

V full version: V 0.4.7 ace4e93.263ba23 OS: linux, Linux version 5.14.0-427.33.1.el9_4.x86_64 (mockbuild@pp-el9) (gcc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3), GNU ld version 2.35.2-43.el9) #1 SMP PREEMPT_DYNAMIC Thu Aug 29 12:00:49 CEST 2024 Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz

getwd: /home/einar/Documents/projects/vlang/active/firebird vexe: /home/einar/.local/lib64/v/v vexe mtime: 2024-09-18 16:47:41

vroot: OK, value: /home/einar/.local/lib64/v VMODULES: OK, value: /home/einar/.vmodules VTMP: OK, value: /tmp/v_1001

Git version: git version 2.43.5 Git vroot status: weekly.2024.37-25-g263ba232 .git/config present: true

CC version: cc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3) thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9

[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.

einar-hjortdal avatar Sep 18 '24 16:09 einar-hjortdal

The problem is the name clashing. See:

Array_u8 string_bytes = firebird__marshal_array_u8(string_bytes(s));

V s.bytes() turns into string_bytes(s) C code, which crashes.

felipensp avatar Sep 20 '24 11:09 felipensp

@spytheman @medvednikov what do you guys suggest for this cases?

felipensp avatar Sep 20 '24 11:09 felipensp

Is there a workaround I can use in the meantime? Development is stalled because of this error

einar-hjortdal avatar Sep 22 '24 07:09 einar-hjortdal

Is there a workaround I can use in the meantime? Development is stalled because of this error

The error is here

fn (mut p WireProtocol) pack_string(s string) {
	string_bytes := marshal_array_u8(s.bytes())
	p.buf = arrays.append(p.buf, string_bytes)
}

Just change string_bytes to strings_bytes_ for now

Delta456 avatar Sep 22 '24 09:09 Delta456

@felipensp would adding a default name mangling for user defined variables, functions, types, etc. and a different one for all internal auto generated types be a viable solution? ie. prefixing all user variables and functions with __VU_ and all internal library variables and std library functions with __VI_?

Tungsten-180 avatar Sep 23 '24 04:09 Tungsten-180

@felipensp would adding a default name mangling for user defined variables, functions, types, etc. and a different one for all internal auto generated types be a viable solution? ie. prefixing all user variables and functions with __VU_ and all internal library variables and std library functions with __VI_?

Yeah, I already thought about this approach. What do you think @medvednikov ?

felipensp avatar Sep 23 '24 22:09 felipensp

Why not postfix userland function names with a hash?

einar-hjortdal avatar Sep 24 '24 10:09 einar-hjortdal

Why not postfix userland function names with a hash?

is there a benefit to a hash over just an int counter like is used for anonymous... I believe structs?

Tungsten-180 avatar Sep 27 '24 23:09 Tungsten-180

Related to issue #17831

felipensp avatar Sep 28 '24 01:09 felipensp

Why not postfix userland function names with a hash?

is there a benefit to a hash over just an int counter like is used for anonymous... I believe structs?

Hashes are more unique, but now I think an int counter is just fine.

einar-hjortdal avatar Oct 28 '24 08:10 einar-hjortdal