Coder Social home page Coder Social logo

Comments (3)

LADSoft avatar LADSoft commented on June 15, 2024

Hi lionfaith!

well the argument of & is supposed to work on lvalues - and usually an
lvalue is taken as something that can be assigned to (e.g. it is the
left side of an assignment statement). Other compilers such as the
microsoft compiler, the borland compiler, and the watcom compiler all
seem to stick to that definition; gcc is the only one I can find that
has this other behavior.

However, that said, the GCC implementation doesn't seem to be out of
bounds, because the latest spec actually defines an lvalue as something
that can refer to an object, and I can see a case being made that the
specific examples you have quoted do indeed refer to objects. So I
will look into implementing it :)

David

lionfaith wrote:

Hello!
I'm trying to compile on windows some SDL based free software project
which AFAIK compiles on Linux (supposedly with gcc) and I envetually
step upon errors on this kind of expressions:
&--theEnemy->thinktime
&(theEnemy->dx -= 0.5)
&(++enemy[WC_BOSS].shield)
&(--engine.eventTimer)
&(star[i].x += (engine.ssx * star[i].speed))
And many others all alike. Although it is used in some kind
optimisation hack, it seems to be valid code. The address-of operator
is not limited to variable, but can be applied on any leftvalue. Or so
it seems.

As '&' operator is hard to search for on the internet, the only clear
reference to this behavior I could find is this:
https://msdn.microsoft.com/en-us/library/64sa8b1e.aspx


Reply to this email directly or view it on GitHub
#10.

from orangec.

LADSoft avatar LADSoft commented on June 15, 2024

hi lionfaith,

I released a new version which will allow the compiler to take the address of objects that are returned from an assignment, a preincrement, or a postincrement. Please let me know whether this is sufficient or if there are other types of expressions gcc lets get by as well.

David

from orangec.

lionfaith avatar lionfaith commented on June 15, 2024

Hi! Great thanks! So fast!
I've downloaded 5.25 and the faulty files now compiles without complains.

from orangec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.