Re: Problem with DATADIR on Mingw

2024-04-12 Thread Reuben Thomas
On Fri, 12 Apr 2024 at 21:20, Bruno Haible  wrote:

> Reuben Thomas wrote:
> > gcc -DHAVE_CONFIG_H -I. -I..  --include configmake.h --include config.h
>

Oh dear, the command-line includes were right in front of me, sorry!


> > ... enchant.c
>
> If you #include these two files from the .c file, rather than from the
> command line, you will have a location where to put '#undef DATADIR'.
>

That works, thanks!

Alternatively, you could swap the two --include options.
>

That didn't work (I guess not surprisingly, as it leaves configmake.h
included before system include files).

In any case, the reason for the two --include options is that in this
project I'm mostly compiling Vala-generated C, and Vala is a bit inflexible
with where it puts #include directives in its generated code. Specifically,
there's no way to get it to put config.h at the top of the file. However, I
don't need to have configmake.h on the command line like this (I can have
it automatically added later by Vala); this was just my being lazy. So, I
think I have a neat solution now.

Many thanks as always for your help.

-- 
https://rrt.sc3d.org


Re: Problem with DATADIR on Mingw

2024-04-12 Thread Bruno Haible
Reuben Thomas wrote:
> gcc -DHAVE_CONFIG_H -I. -I..  --include configmake.h --include config.h
> ... enchant.c

If you #include these two files from the .c file, rather than from the
command line, you will have a location where to put '#undef DATADIR'.

Alternatively, you could swap the two --include options.
This would be in line with the comment I added in 2008:
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=4d45d1e67873d2988c923aa182c26e4d6cfe0d0e
configmake.h should be included *after* all system include files.
What you are currently doing is to include it *before* all system
include files.

Bruno






Re: Problem with DATADIR on Mingw

2024-04-12 Thread Reuben Thomas
On Fri, 12 Apr 2024 at 18:55, Bruno Haible  wrote:

> Reuben Thomas wrote:
> > With up-to-date gnulib (and I can't see any relevant changes for some
> > years), I am getting the following error while using the configmake
> module
> > and building on Mingw 64 x86_64:
> >
> > In file included from :
> > C:/msys64/mingw64/include/objidl.h:10677:3: error: expected identifier or
> > '(' before string constant
> > 10677 | } DATADIR;
> > | ^~~
>
> Many packages work around this by doing '#undef DATADIR' somewhere [1].
>

Thanks very much for the pointer, I was able to copy this workaround. It
seems that the comment at that reference understates the case; it says:

/* This is a hack for Windows known directory support.
 * DATADIR (autotools-generated constant) is a type defined in objidl.h
 * so we must #undef it before including shlobj.h in order to avoid a
 * name clash. */

But I only include windows.h (not shlobj.h), and that seems to be enough to
trigger the problem.

For more investigation, we would need the complete include files stack,
> as gcc prints it after "In file included ...".
>

Unfortunately, the output (plus the command, for reasons you will see) in
my case is:

gcc -DHAVE_CONFIG_H -I. -I..  --include configmake.h --include config.h
-I.. -isystem ../lib -isystem ../lib -IC:/msys64/mingw64/include/glib-2.0
-IC:/msys64/mingw64/lib/glib-2.0/include -fanalyzer -fstrict-flex-arrays
-Wall -Warith-conversion -Wbad-function-cast -Wcast-align=strict
-Wdate-time -Wdisabled-optimization -Wdouble-promotion
-Wduplicated-branches -Wduplicated-cond -Wextra -Wformat-signedness
-Winit-self -Winline -Winvalid-pch -Wlogical-op -Wmissing-declarations
-Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs
-Wnull-dereference -Wold-style-definition -Wopenmp-simd
-Woverlength-strings -Wpacked -Wpointer-arith -Wshadow -Wstack-protector
-Wstrict-flex-arrays -Wstrict-overflow -Wstrict-prototypes
-Wsuggest-attribute=cold -Wsuggest-attribute=const
-Wsuggest-attribute=format -Wsuggest-attribute=malloc
-Wsuggest-attribute=noreturn -Wsuggest-attribute=pure
-Wsuggest-final-methods -Wsuggest-final-types -Wsync-nand -Wtrampolines
-Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations
-Wunused-macros -Wvariadic-macros -Wvector-operation-performance -Wvla
-Wwrite-strings -Warray-bounds=2 -Wattribute-alias=2 -Wbidi-chars=any,ucn
-Wformat-overflow=2 -Wformat=2 -Wformat-truncation=2 -Wshift-overflow=2
-Wuse-after-free=3 -Wunused-const-variable=2 -Wvla-larger-than=4031
-Wno-analyzer-malloc-leak -DG_LOG_DOMAIN='"libenchant"'   -g -O2 -MT
enchant.o -MD -MP -MF $depbase.Tpo -c -o enchant.o enchant.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from :
C:/msys64/mingw64/include/objidl.h:10677:3: error: expected identifier or
'(' before string constant
10677 | } DATADIR;
  |   ^~~

I cannot see in what sense the file was included from the command line.

-- 
https://rrt.sc3d.org


Re: Problem with DATADIR on Mingw

2024-04-12 Thread Bruno Haible
Reuben Thomas wrote:
> With up-to-date gnulib (and I can't see any relevant changes for some
> years), I am getting the following error while using the configmake module
> and building on Mingw 64 x86_64:
> 
> In file included from :
> C:/msys64/mingw64/include/objidl.h:10677:3: error: expected identifier or
> '(' before string constant
> 10677 | } DATADIR;
> | ^~~

Many packages work around this by doing '#undef DATADIR' somewhere [1].

For more investigation, we would need the complete include files stack,
as gcc prints it after "In file included ...".

Bruno

[1] 
https://sources.debian.org/src/evince/46.0-1/cut-n-paste/libdazzle/dzl-file-manager.c/?hl=32#L32