|
From: Nicholas N. <nj...@ca...> - 2002-11-06 15:02:03
|
On Wed, 6 Nov 2002, Josef Weidendorfer wrote: > > #ifndef __VG_SKIN_H > > #define __VG_SKIN_H > > This prevents only multiple inclusion when compiling one file. For multiple > sources including skin.h, you get a definition in each object file... Ugh, pft, of course. > Perhaps define a macro VG_DEFINE_SKIN_VERSION or somthing like this > and instruct the skin developer to put this in ONE of his source files. Yeah... although I can't help the feeling that there should be a way of doing it so that the skin-writer doesn't have to do anything more than #include vg_skin.h... bleh. Unless... if a variable is defined as __attribute__ ((weak)), it can be defined by multiple .o files and the linker won't complain, so long as an initial value is provided... it just uses whichever definition comes first. All the definitions would be the same because they all arise from #include'ing vg_skin, so this should be ok. I think. Unless there are other complications that I'm not aware of (almost undoubtedly). I guess one danger of this would be that the skin-writer could overwrite the variables with his own strong versions, but then again the skin-writer can already do a million stupid things that will screw up the core so that doesn't make much difference. N |
|
From: Jeremy F. <je...@go...> - 2002-11-06 16:36:46
|
On Wed, 2002-11-06 at 07:01, Nicholas Nethercote wrote: > Yeah... although I can't help the feeling that there should be a way of > doing it so that the skin-writer doesn't have to do anything more than > #include vg_skin.h... bleh. Well, the skin writer has to do some syntactic mucking about to set up all the skin entrypoints, so a single extra line isn't going to hurt too much. > Unless... if a variable is defined as __attribute__ ((weak)), it can be > defined by multiple .o files and the linker won't complain, so long as an > initial value is provided... it just uses whichever definition comes > first. All the definitions would be the same because they all arise from > #include'ing vg_skin, so this should be ok. I think. Unless there are > other complications that I'm not aware of (almost undoubtedly). I think that's trying to hide too much clever stuff. For example, its another thing to go wrong in subtle ways if the various .o files get different definitions. > I guess one danger of this would be that the skin-writer could overwrite > the variables with his own strong versions, but then again the skin-writer > can already do a million stupid things that will screw up the core so that > doesn't make much difference. Given the number of other things a skin writer has to initialize and/or register, a single extra one for interface version is not a huge burden. Far better than making things to clever-clever which becomes confusing if you're trying to track down a problem later. J |
|
From: Nicholas N. <nj...@ca...> - 2002-11-08 15:53:18
|
On 6 Nov 2002, Jeremy Fitzhardinge wrote: > Given the number of other things a skin writer has to initialize and/or > register, a single extra one for interface version is not a huge > burden. Far better than making things to clever-clever which becomes > confusing if you're trying to track down a problem later. I took your advice. There's now a macro VG_DETERMINE_INTERFACE_VERSION that each skin has to use exactly once. Failure to use it results in link errors when building the skin. Hopefully it should work ok. N |