Chris Wolf
2001-Oct-17 11:00 UTC
[vorbis-dev] win32sdk shared memory issue -- proposed change of code
It was recently brought to my attention by "Ram'on Garc'ia Fern'andez <ramon@jl1.quim.ucm.es>" that there is yet an even simpler solution to the issue of cross-DLL access of variables in the data segment. Although a variable may be exported either from the module definition file, or explicitly via _cdeclspec(dllexport) -- unlike procedures (functions), it is mandatory for a DLL client to access that variable via _cdeclspec(dllimport). It is unnecessary to allocate dynamic memory and then copy pointers to that allocated memory, as is done with the vorbis/win32/src/shmmap.h and vorbis/win32/src/shmmap_c.h stuff. In otherwords, we've come full circle -- it looks like the linking paradigm in Windows is closer to what would be expected when developing under UNIX, after all... ...well -- almost, as mentioned, the "_cdeclspec(dllimport)" attribute is required, such that a modification of "vorbis/lib/registry.h" is required which would look like: #if defined(_MSC_VER) && defined(DLL_IMPORT) # define EXTERN _declspec(dllimport) extern #else # define EXTERN extern #endif EXTERN vorbis_func_time *_time_P[]; EXTERN vorbis_func_floor *_floor_P[]; EXTERN vorbis_func_residue *_residue_P[]; EXTERN vorbis_func_mapping *_mapping_P[]; I realize the aesthetics of having "EXTERN" instead of "extern" may be an issue on non-win32 platforms, (although in this case it would still preprocess out to "extern") so I thought I'd present the proposed change to the list before commiting to CVS... --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Matthijs Laan
2001-Oct-17 12:57 UTC
[vorbis-dev] win32sdk shared memory issue -- proposed change of code
On 17 Oct 2001, you wrote in internal.mail.vorbis-dev:> I realize the aesthetics of having "EXTERN" instead of "extern" may be > an issue on non-win32 platforms, (although in this case it would still > preprocess out to "extern") so I thought I'd present the proposed > change to the list before commiting to CVS...BTW, some remarks about the win32 batch files: You should replace "exit"s by a "goto" to the end of the file, because using "exit" closes the console - it does *not* return to the calling batch file (as you expect in mkmak.bat when calling mfmacro.bat). One also doesn't get a chance of seeing the error messages before exiting when there are some - the console just closes without showing them. "Sleep" doesn't exist on my system either (Clean Win2000sp2/msvc6sp5pp install). And before "echo Generating makefiles, please wait..." in mkmak.bat the user should install the macro file by opening msdev, going to Tools -> Add- ins and Macro Files and ticking the checkbox for "oggvorbis". Then the SDKHOME needs to be set before running the other batch files. Hope this helps, Matthijs --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Dimitry Andric
2001-Oct-18 14:51 UTC
[vorbis-dev] win32sdk shared memory issue -- proposed change of code
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2001-10-17 at 20:00:38 Chris Wolf wrote: CW> #if defined(_MSC_VER) && defined(DLL_IMPORT) CW> # define EXTERN _declspec(dllimport) extern CW> #else CW> # define EXTERN extern CW> #endif CW> EXTERN vorbis_func_time *_time_P[]; CW> EXTERN vorbis_func_floor *_floor_P[]; CW> EXTERN vorbis_func_residue *_residue_P[]; CW> EXTERN vorbis_func_mapping *_mapping_P[]; I propose changing that to: #if defined(_WIN32) && defined(VORBISDLL_IMPORT) # define EXTERN __declspec(dllimport) extern #else # define EXTERN extern #endif EXTERN vorbis_func_time *_time_P[]; EXTERN vorbis_func_floor *_floor_P[]; EXTERN vorbis_func_residue *_residue_P[]; EXTERN vorbis_func_mapping *_mapping_P[]; The defined(_WIN32) is because MSVC is not the only Win32 compiler, and almost all other Win32 compilers grok the __declspec stuff anyway, for compatibility reasons. (Btw, according to the Microsoft docs, it's __declspec, not _declspec.) The defined(VORBISDLL_IMPORT) is because DLL_IMPORT is simply too generic. There might be more imported DLLs in a Win32 project. ;-) Cheers, - -- Dimitry Andric <dim@xs4all.nl> PGP Key: http://www.xs4all.nl/~dim/dim.asc Fingerprint: 7AB462D2CE35FC6D42394FCDB05EA30A2E2096A3 Lbh ner abj va ivbyngvba bs gur QZPN -----BEGIN PGP SIGNATURE----- Version: PGP 6.5i Comment: http://www.gn.apc.org/duncan/stoa_cover.htm iQA/AwUBO89A5rBeowouIJajEQKOGwCeLvDeip82w+TIa6zW88LgCXh3XNAAoIZo jDSOof7sVycAqGEvq/vPciTM =K77F -----END PGP SIGNATURE----- --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.