Connecting Tech Pros Worldwide Forums | Help | Site Map

Implement a Pragma.

Che
Guest
 
Posts: n/a
#1: Jul 22 '05
Hi,

I am unsure of this message should be posted here. If not please let
me know the appropriate group.

I was wondering how i could implement my own pragma.
Say #pragma to_asm_code {function_name}
{function_name} is an assembly routine. I believe some compilers
provide this feature by mechanism of "FastCall". I don't want anything
complicated. All I wish to do is the language must recognize this as a
pragma, push the return address and transfer control to the assembly
routine.

Thanks,
Che

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Implement a Pragma.


Che wrote:[color=blue]
> I am unsure of this message should be posted here. If not please let
> me know the appropriate group.
>
> I was wondering how i could implement my own pragma. [...][/color]

#pragma directive is defined to cause the preprocessor to behave in
some implementation-defined way, therefore there is nothing in the C++
language itself that would help you. You need to pose this question
to the developers of the compiler you're using.

I know one compiler for which you can get the source code: GNU C++.
You could add your special pragma to it if you feel that it's something
you need and/or want to do. After that you will have your own special
edition of the compiler or you could share it with everybody interested
by submitting your code back to GCC project folks. Try asking in
gnu.g++ or gnu.g++.help.

V
David Lindauer
Guest
 
Posts: n/a
#3: Jul 22 '05

re: Implement a Pragma.




Che wrote:
[color=blue]
> Hi,
>
> I am unsure of this message should be posted here. If not please let
> me know the appropriate group.
>
> I was wondering how i could implement my own pragma.
> Say #pragma to_asm_code {function_name}
> {function_name} is an assembly routine. I believe some compilers
> provide this feature by mechanism of "FastCall". I don't want anything
> complicated. All I wish to do is the language must recognize this as a
> pragma, push the return address and transfer control to the assembly
> routine.
>
> Thanks,
> Che[/color]

in this specific case you can just declare the function and call it, e.g.:

extern "C" void function_name() ;

then

function_name() to call it.

And that should do exactly what you need although you may have to add an
'_' character to the name in your assembly code.

the 'fastcall' pragma is I think a watcom C/C++ thing, what it means is
pass the arguments in registers instead of pushing them on the stack. It
doesn't do anything if you don't have arguments.

David
Che
Guest
 
Posts: n/a
#4: Jul 22 '05

re: Implement a Pragma.


Thanks Victor.



Victor Bazarov <v.Abazarov@comAcast.net> wrote in message news:<oQLmd.11066$Ae.1256@newsread1.dllstx09.us.to .verio.net>...[color=blue]
> Che wrote:[color=green]
> > I am unsure of this message should be posted here. If not please let
> > me know the appropriate group.
> >
> > I was wondering how i could implement my own pragma. [...][/color]
>
> #pragma directive is defined to cause the preprocessor to behave in
> some implementation-defined way, therefore there is nothing in the C++
> language itself that would help you. You need to pose this question
> to the developers of the compiler you're using.
>
> I know one compiler for which you can get the source code: GNU C++.
> You could add your special pragma to it if you feel that it's something
> you need and/or want to do. After that you will have your own special
> edition of the compiler or you could share it with everybody interested
> by submitting your code back to GCC project folks. Try asking in
> gnu.g++ or gnu.g++.help.
>
> V[/color]
Closed Thread


Similar C / C++ bytes