Re: Debug build compile error in 'gobject/gobject.c'

2016-08-03 Thread Emmanuele Bassi
Hi;

On 3 August 2016 at 18:36, John Emmas  wrote:
> Hi there - I just came across a problem after updating libglib to the latest
> git master (my last update was about a fortnight ago).
>
> I'm building with MSVC 8 and when I try to compile 'gobject/gobject.c' the
> Release version compiles fine but compiling in Debug mode gives me an error
> around these lines at the end of function 'void g_object_type_init (void)
> (approximately line 400):-
>
>   GOBJECT_IF_DEBUG (OBJECTS,
>   {
>   debug_objects_ht = g_hash_table_new (g_direct_hash, NULL);
> #ifndef G_HAS_CONSTRUCTORS
>   g_atexit (debug_objects_atexit);
> #endif /* G_HAS_CONSTRUCTORS */
>   });
>
> The error I see is:-
>
>   gobject\gobject.c(403) : error C2121: '#' : invalid character :
> possibly the result of a macro expansion
>
> AFAICT gobject.c itself hasn't changed recently so is it possible that
> GOBJECT_IF_DEBUG has changed somehow?  The Release build compiles okay so I
> guess that seems plausible.  Thanks,

This is likely a MSVC 8 issue. The GOBJECT_IF_DEBUG macro expands the
second argument to a code block, and it seems MSVC 8 has issues when
that includes a conditional pre-processor directive.

GOBJECT_IF_DEBUG hasn't changed since 2014, and the same commit
introduced the use you see failing.

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Debug build compile error in 'gobject/gobject.c'

2016-08-03 Thread Arnavion
I don't believe you're allowed to legally use macros inside a macro
expansion - 
https://stackoverflow.com/questions/19111383/ifdef-inside-a-macro-call-works-with-gcc-but-not-with-msvc

On Wed, Aug 3, 2016 at 10:46 AM, Emmanuele Bassi  wrote:
> Hi;
>
> On 3 August 2016 at 18:36, John Emmas  wrote:
>> Hi there - I just came across a problem after updating libglib to the latest
>> git master (my last update was about a fortnight ago).
>>
>> I'm building with MSVC 8 and when I try to compile 'gobject/gobject.c' the
>> Release version compiles fine but compiling in Debug mode gives me an error
>> around these lines at the end of function 'void g_object_type_init (void)
>> (approximately line 400):-
>>
>>   GOBJECT_IF_DEBUG (OBJECTS,
>>   {
>>   debug_objects_ht = g_hash_table_new (g_direct_hash, NULL);
>> #ifndef G_HAS_CONSTRUCTORS
>>   g_atexit (debug_objects_atexit);
>> #endif /* G_HAS_CONSTRUCTORS */
>>   });
>>
>> The error I see is:-
>>
>>   gobject\gobject.c(403) : error C2121: '#' : invalid character :
>> possibly the result of a macro expansion
>>
>> AFAICT gobject.c itself hasn't changed recently so is it possible that
>> GOBJECT_IF_DEBUG has changed somehow?  The Release build compiles okay so I
>> guess that seems plausible.  Thanks,
>
> This is likely a MSVC 8 issue. The GOBJECT_IF_DEBUG macro expands the
> second argument to a code block, and it seems MSVC 8 has issues when
> that includes a conditional pre-processor directive.
>
> GOBJECT_IF_DEBUG hasn't changed since 2014, and the same commit
> introduced the use you see failing.
>
> Ciao,
>  Emmanuele.
>
> --
> https://www.bassi.io
> [@] ebassi [@gmail.com]
> ___
> gtk-devel-list mailing list
> gtk-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-devel-list
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Debug build compile error in 'gobject/gobject.c'

2016-08-03 Thread John Emmas

On 03/08/2016 18:46, Emmanuele Bassi wrote:

This is likely a MSVC 8 issue. The GOBJECT_IF_DEBUG macro expands the
second argument to a code block, and it seems MSVC 8 has issues when
that includes a conditional pre-processor directive.

GOBJECT_IF_DEBUG hasn't changed since 2014, and the same commit
introduced the use you see failing.



That's what confused me.  The last commit date for gobject.c seems to be 
25th May 2014 and yet the same code section looked like this only a 
fortnight ago:-


#ifdef  G_ENABLE_DEBUG
IF_DEBUG (OBJECTS)
  {
debug_objects_ht = g_hash_table_new (g_direct_hash, NULL);
#ifndef G_HAS_CONSTRUCTORS
g_atexit (debug_objects_atexit);
#endif /* G_HAS_CONSTRUCTORS */
  }
#endif/* G_ENABLE_DEBUG */

The above code compiles okay (or at least, it did a fortnight ago) and 
VC8 is supposedly a supported compiler, so will a fix be possible?


John
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Debug build compile error in 'gobject/gobject.c'

2016-08-03 Thread Arnavion
The confusion is arising from the fact that the working code is in 2.48

https://github.com/GNOME/glib/blob/glib-2-48/gobject/gobject.c#L398-L406

The non-working code is in master.

On Wed, Aug 3, 2016 at 11:35 AM, John Emmas  wrote:
> On 03/08/2016 18:46, Emmanuele Bassi wrote:
>>
>> This is likely a MSVC 8 issue. The GOBJECT_IF_DEBUG macro expands the
>> second argument to a code block, and it seems MSVC 8 has issues when
>> that includes a conditional pre-processor directive.
>>
>> GOBJECT_IF_DEBUG hasn't changed since 2014, and the same commit
>> introduced the use you see failing.
>>
>
> That's what confused me.  The last commit date for gobject.c seems to be
> 25th May 2014 and yet the same code section looked like this only a
> fortnight ago:-
>
> #ifdef  G_ENABLE_DEBUG
> IF_DEBUG (OBJECTS)
>   {
> debug_objects_ht = g_hash_table_new (g_direct_hash, NULL);
> #ifndef G_HAS_CONSTRUCTORS
> g_atexit (debug_objects_atexit);
> #endif /* G_HAS_CONSTRUCTORS */
>   }
> #endif/* G_ENABLE_DEBUG */
>
> The above code compiles okay (or at least, it did a fortnight ago) and VC8
> is supposedly a supported compiler, so will a fix be possible?
>
> John
>
> ___
> gtk-devel-list mailing list
> gtk-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-devel-list
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Debug build compile error in 'gobject/gobject.c'

2016-08-03 Thread Alan Coopersmith

On 08/ 3/16 11:35 AM, John Emmas wrote:

On 03/08/2016 18:46, Emmanuele Bassi wrote:

This is likely a MSVC 8 issue. The GOBJECT_IF_DEBUG macro expands the
second argument to a code block, and it seems MSVC 8 has issues when
that includes a conditional pre-processor directive.

GOBJECT_IF_DEBUG hasn't changed since 2014, and the same commit
introduced the use you see failing.



That's what confused me.  The last commit date for gobject.c seems to be 25th
May 2014 and yet the same code section looked like this only a fortnight ago:-


Commit dates aren't the same as the date a commit was pushed/pulled into the
repo.

https://git.gnome.org/browse/glib/commit/gobject/gobject.c?id=42dad59cc10c5b44fac23e93004b17baeb750500
shows the author wrote the code on 2014-05-25, but it wasn't integrated
until 2016-07-17.

--
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Debug build compile error in 'gobject/gobject.c'

2016-08-03 Thread Emmanuele Bassi
Hi;

On 3 August 2016 at 19:35, John Emmas  wrote:
> On 03/08/2016 18:46, Emmanuele Bassi wrote:
>>
>> This is likely a MSVC 8 issue. The GOBJECT_IF_DEBUG macro expands the
>> second argument to a code block, and it seems MSVC 8 has issues when
>> that includes a conditional pre-processor directive.
>>
>> GOBJECT_IF_DEBUG hasn't changed since 2014, and the same commit
>> introduced the use you see failing.
>>
>
> That's what confused me.  The last commit date for gobject.c seems to be
> 25th May 2014 and yet the same code section looked like this only a
> fortnight ago:-
>
> #ifdef  G_ENABLE_DEBUG
> IF_DEBUG (OBJECTS)
>   {
> debug_objects_ht = g_hash_table_new (g_direct_hash, NULL);
> #ifndef G_HAS_CONSTRUCTORS
> g_atexit (debug_objects_atexit);
> #endif /* G_HAS_CONSTRUCTORS */
>   }
> #endif/* G_ENABLE_DEBUG */
>
> The above code compiles okay (or at least, it did a fortnight ago) and VC8
> is supposedly a supported compiler, so will a fix be possible?

Care to file a bug with a link to this thread?

I'll try to come up with a patch for all the cases of this macro
exploiting undefined behaviour.

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Debug build compile error in 'gobject/gobject.c'

2016-08-04 Thread John Emmas

On 03/08/2016 23:07, Emmanuele Bassi wrote:


Care to file a bug with a link to this thread?

I'll try to come up with a patch for all the cases of this macro
exploiting undefined behaviour.



Thanks, I just filed bug #769504:-

https://bugzilla.gnome.org/show_bug.cgi?id=769504

I'm not sure if it's technically a blocker but I marked it as a blocker 
because it prevents compilation. :-)


John
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list