I spent a few minutes yesterday playing with the libdispatch sources to see how far I could get building under Visual Studio. As expected, it choked when presented with various useful gcc extensions, such as named structure initializers, differences in macro handling, and so forth. All of these differences are fairly easily resolved, with the exception of the gcc-specific 'typeof' operator. I'm not sure how to provide similar behavior under the Visual C++ compiler, as I don't think it has a mechanism to determine the static type of an expression at runtime. Can anyone comment on how this is resolved for the Apple build of libdispatch (i.e., the version that ships with Safari/WebKit)? Thanks, -Brent
[ Adding Kevin explicitly to this discussion ] On Apr 15, 2011, at 12:04 PM, Brent Fulgham wrote:
I spent a few minutes yesterday playing with the libdispatch sources to see how far I could get building under Visual Studio. As expected, it choked when presented with various useful gcc extensions, such as named structure initializers, differences in macro handling, and so forth.
All of these differences are fairly easily resolved, with the exception of the gcc-specific 'typeof' operator. I'm not sure how to provide similar behavior under the Visual C++ compiler, as I don't think it has a mechanism to determine the static type of an expression at runtime.
Can anyone comment on how this is resolved for the Apple build of libdispatch (i.e., the version that ships with Safari/WebKit)?
Hi Brent, I think (but can't say for sure) that this may be a job for clang, specifically the -rewrite-objc flag. You can see some discussion on it here: http://lists.apple.com/archives/objc-language/2009/Apr/msg00030.html I'm not intimately familiar with how it's used by the Windows port, but I believe the general idea is to rewrite the blocks and other extensions into a dialect of C that is vanilla enough for Visual Studio to process. I'll defer to Kevin on the details and whether or not there is an actual merit to this approach or if it's only useful for a limited number of scenarios, but this snippet alone may be enough to get your investigations pointed in the right direction! - Jordan
Le 15 avr. 2011 à 21:04, Brent Fulgham a écrit :
I spent a few minutes yesterday playing with the libdispatch sources to see how far I could get building under Visual Studio. As expected, it choked when presented with various useful gcc extensions, such as named structure initializers, differences in macro handling, and so forth.
All of these differences are fairly easily resolved, with the exception of the gcc-specific 'typeof' operator. I'm not sure how to provide similar behavior under the Visual C++ compiler, as I don't think it has a mechanism to determine the static type of an expression at runtime.
typeof is evaluated at compile time, not at runtime. I think you can use decltype in Visual Studio 2010 to get something similar. -- Jean-Daniel
On Sat, Apr 16, 2011 at 09:43, Jean-Daniel Dupas <devlists@shadowlab.org>wrote:
Le 15 avr. 2011 à 21:04, Brent Fulgham a écrit :
I spent a few minutes yesterday playing with the libdispatch sources to see how far I could get building under Visual Studio. As expected, it choked when presented with various useful gcc extensions, such as named structure initializers, differences in macro handling, and so forth.
All of these differences are fairly easily resolved, with the exception of the gcc-specific 'typeof' operator. I'm not sure how to provide similar behavior under the Visual C++ compiler, as I don't think it has a mechanism to determine the static type of an expression at runtime.
typeof is evaluated at compile time, not at runtime.
I think you can use decltype in Visual Studio 2010 to get something similar.
-- Jean-Daniel
Boost has a typeof implementation for Visual Studio. http://www.boost.org/doc/libs/1_34_0/doc/html/typeof/ Not saying that libdispatch should depend on boost though. — Federico Bianco Prevot
participants (4)
-
Brent Fulgham
-
Federico Bianco Prevot
-
Jean-Daniel Dupas
-
Jordan K. Hubbard