tpm-emulator icon indicating copy to clipboard operation
tpm-emulator copied to clipboard

add extern to function declarations

Open jandryuk opened this issue 3 years ago • 2 comments

Code compiled with gcc10 will not link properly due to multiple definition of the same function.

ld: /home/abuild/rpmbuild/BUILD/xen-4.8.20191211T160002.8db85532cb/non-dbg/stubdom/vtpm/vtpm.a(vtpm_cmd.o):(.bss+0x28): multiple definition of `tpm_malloc'; /home/abuild/rpmbuild/BUILD/xen-4.8.20191211T160002.8db85532cb/non-dbg/stubdom/vtpm/vtpm.a(vtpm.o):(.bss+0x728): first defined here

Signed-off-by: Olaf Hering [email protected] Reviewed-by: Jason Andryuk [email protected] Acked-by: Samuel Thibault [email protected] Reviewed-by: Ian Jackson [email protected] Release-acked-by: Paul Durrant [email protected]

Move over from xen repo.

Signed-off-by: Jason Andryuk [email protected]

jandryuk avatar Mar 16 '21 15:03 jandryuk

I was briefly confused by this, as functions are extern by default in C, but these are function pointers, so the extern makes a difference and resolves the issue.

Justin-Otto avatar Sep 09 '21 12:09 Justin-Otto

Thanks, I fall into this problem with gcc 11.4 and find that gcc 10 change its default behavior about global variable (defaulted to -fcommon for gcc < 10 and -fno-common for gcc >= 10). You PR is the right way to correct that though

fmartinsons avatar Nov 29 '23 13:11 fmartinsons