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

Error 'function modifier cannot be used on a variable' #1246

Open
Baron-von-Riedesel opened this issue Mar 1, 2024 · 3 comments
Open

Error 'function modifier cannot be used on a variable' #1246

Baron-von-Riedesel opened this issue Mar 1, 2024 · 3 comments
Labels
bug C++ C++ compiler

Comments

@Baron-von-Riedesel
Copy link

Baron-von-Riedesel commented Mar 1, 2024

The error may be emitted by the C++ compiler wpp386 if your C++ code contains a std include file, i.e. math.h:

#include <math.h>

extern "C" void asmfunc(int, int );

int main ( int arcc, char * *argv )
{
	asmfunc(1, 2);
	return( 0 );
}

it happens only if the compiler option -ecc is given, though. This option is needed here to make the compiler add a preceding underscore to the external ( _asmfunc ).

@jmalak
Copy link
Member

jmalak commented Mar 1, 2024

-ecc option change calling convention and part of this is name change in object file.
If you want only change the symbol name you need not use -ecc option.
You can use following construct to define real symbol for C/C++ symbol with prefixed underscore characters.

#pragma aux asmfunc "_*"

@Baron-von-Riedesel
Copy link
Author

Baron-von-Riedesel commented Mar 1, 2024

-ecc option change calling convention and part of this is name change in object file.

Are you sure about that? I've got the impression that options -3s/4s/5s or -3r/4r/5r actually determine the calling convention - while the -ecc option affects the name only.

The #pragma hack is ok, but still, the C++ compiler should not emit such strange error messages just because option -ecc is given. I noticed, however, that this bug report is more or less a double, there's already #1187

@jmalak
Copy link
Member

jmalak commented Mar 1, 2024

Yes, the problem with the -ec... options for C++ compiler is known.
But -ecc not only changes the name, but also changes the passing of parameters from the registers to the stack.
-ecc is similar to -3s, but not the same. anyway, the -3r option passes the parameters through the registers.
Combining -3r or -3s with any -ec.. option is inherently nonsense and can lead to unpredictable behavior.
You should use either the -ec... or -3r or -3s option. Now -3r or -3s is for backwards compatibility because -ec... handles things correctly.
Anyway by #pragma aux you can define default convention for parameter passing and naming etc. it can do same thing as -3r or -3s or any -ec.. option because internaly these options manipulate with default convention. generaly #pragma aux can handle any feature of calling convention but -ec.. or -3s or -3r are limited to specific cases.

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

No branches or pull requests

2 participants