help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C/C++ Extended Assembly Constraint Confusion


From: Jan Seiffert
Subject: Re: C/C++ Extended Assembly Constraint Confusion
Date: Mon, 19 Mar 2012 21:41:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120303 Firefox/10.0.1 SeaMonkey/2.7.1

woessner@gmail.com schrieb:
[snip - static const memory asm input]
> Can anyone explain why this works with gcc but not g++?
> 

Because C++ language rules are "different" (to put it nicely) when it comes to
const.
Calling C++ C++ was the worst mistake ever made, it is not C 2.0, it is a
different language where certain aspects of C are totally broken.

In C const is more like a hint/promise (which then may put things into read only
memory, if avail.), while in C++ const is actually a strong guarantee, that
makes the variable an real immediate which does not "exist" anywhere in memory.
It may still exist in memory for technical reasons, but you can not access it,
so you can't pass it into an memory asm input.

You may:
a) filter the const with an #ifndef __cplusplus
b) ask the compiler to put the const into a xmm register for you, beware of
clobbering it (you already did so with the "x" constrain for the other
constants, so why not for this?)
c) does it help if you use the old extern-"C"-trick around the function?

> Thanks in advance,
> Bill

Greetings
        Jan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]