Menu

#520 Make device-specific declarations static

open
nobody
None
5
2016-12-30
2016-12-30
No

SDCC comes with some device-specific headers, such as C8051F120 for easier use of device-specific functionality. These contain lots of declarations, resulting in frequenct name clashes. When porting the Whetstone benchmark to the C8051F120, I thus used my own sfr declarations to avoid conflicts.

I think there could be an elegant solution to the problem: Make the sfr declarations (except _XPAGE) static, so they don't conflict with names from other modules.

Philipp

Discussion

  • Maarten Brock

    Maarten Brock - 2016-12-30

    Would you want to change the behaviour of the __sfr keyword or the SFR macro in compiler.h or all instances in c8051f120.h? Many C8051 include files can do with an update to use compiler.h in the first place btw. About a third of them currently use it (e.g. C8051F336.h).

     
    • Philipp Klaus Krause

      I probably would have changed the instances in c8051f120.h, since it seems like the smallest change to get stuff working. But there could be better solutions.

      Philipp

       
      • Maarten Brock

        Maarten Brock - 2017-05-14

        I think changing the __sfr keyword to always be static unless explicitly made extern would have been the best solution. But it will break current _XPAGE declarations in existing header files and we can only fix the ones we provide.

        The next best solution is to change the SFR macro. We could add another one for _XPAGE kind of use. Maybe it's even possible to check the name against '_XPAGE'.

        Changing all sfr declarations in all header files seems like too big a job.

         

Log in to post a comment.