Re: 'glib/gio/glocalfile.c' no longer compiles with MSVC

On 11/09/2013 23:16, A. Walton wrote:
> The best way to get this reviewed is to get on IRC, get the attention of one of the GLib > maintainers, and have them review the code. Ryan Lortie (desrt on IRC) wrote that code,
> so he's probably the first person to run this change by.

On 11/09/2013 22:27, Fan Chun-wei wrote:
> It is indeed a very recent update to glocalfile.c, due to the use of dirent. I have opened > a bug for it few days ago at, so > if someone can take a look at it as a stable release is around the corner it would be great.

Thanks guys,

Before I add anything to Fan's bug report (and before visiting IRC) let me just create a record here of what I've found this morning - because it's definitely a bit baffling and I think it needs some lengthy consideration....

The actual problem is a simple one. the sources for opendir() / readdir() etc can be found in '<glib>/build/win32/dirent/dirent.c'. But that source file is not included in any of the MSVC projects so when you try to call one of those functions you end up with a missing symbol. That's what's happening in Ryan's latest changes to 'gio'glocalfile.c' - but it's not quite that simple....

opendir() / readdir() etc are already getting called all over the place - so how has this been working up until now??? There are two explanations:-

1) Some of the files which use opendir() have a complementary Windows version which doesn't use it. For example 'glib/gspawn.c' has a complmentary file 'glib/gspawn-win32.c' which doesn't use those functions. Likewise, 'gio/gcontentype.c' has a complmentary file 'gio/gcontenttype-win32.c'. So that's half the explanation.

2) There are some other files which use opendir() etc (e.g. 'glib/gdir.c') but there's no complementary gdir-win32.c. So how does it work? Here's an example, using 'closedir()'

      #ifdef G_OS_WIN32
            _wclosedir (whatever);

So you can see that for Windows, 'closedir()' isn't getting called. Instead, we're calling '_wclosedir()'.

But here's the problem... _wclosedir() is also implemented in dirent.c (the file that we forgot to include in our MSVC projects). So if the compiler complains about not being able to find closedir() why does it not complain when it can't find _wclosedir()???

_wclosedir() / _wopendir() / _wreaddir() etc must be getting picked up from somewhere else on my system but for the life of me I can't see anywhere else where they'd be getting picked up.

In any event, adding dirent.c to my glib project doesn't help much. It's symbols aren't exported so if you build glib as a Windows DLL, the built DLL doesn't export any of those functions so they can't be called as they are at present (from gio, for example).

This probably needs a bit of in-depth thought but I agree with Fan. It needs to be fixed with some urgency!! Depending on time zones I'd be happy to collaborate on IRC and I could help with testing if necessary.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]