DevO2012 / marisa-trie

Automatically exported from code.google.com/p/marisa-trie
Other
0 stars 0 forks source link

Compilation fails under certain circumstances in Xcode with stdio.h colliding with system include #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The Xcode compiler get's 'confused' and can't include <cstdio> complaining that 
FILE is not a member of global namespace std.
After digging around for hours we suspected the file 'stdio.h' in marisa trie 
to 'confuse' the compiler and stop looking for the 'real' stdio.h.
While marisa trie includes stdio.h using two different ways - once with 
"stdio.h" and other times with <stdio.h> to distinguish between user and system 
include - this still didn't resolve our problem.

We had to rename the marisa trie stdio.h into stdio_xx.h (example name) to 
avoid this issue and change the sources accordingly.

What steps will reproduce the problem?
1. Create a project that uses marisa trie
2. Compile and 'install' the project into a directory
3. Include the marisa trie headers 

What is the expected output? What do you see instead?
Expected output was successfull compilation - we saw an error saying that 
<cstdio> in marisa's stdio.h couldn't be included

What version of the product are you using? On what operating system?
0.2.4 on OSX/iOS

Please provide any additional information below.

We'd be very happy if marisa could use 'non standard' include file names ... 
e.g. rename stdio.h, iostream, ... to something 'custom'

Thanks

Original issue reported on code.google.com by willomit...@gmail.com on 17 Aug 2013 at 9:25

GoogleCodeExporter commented 9 years ago
Thank you for your report and solution!

I'll test the problem tonight.

Maybe, I'll try using #include "marisa/stdio.h" instead of #include "stdio.h" 
so as to avoid the problem, because "marisa/stdio.h" is already a part of 
libmarisa's API.

Original comment by susumu.y...@gmail.com on 19 Aug 2013 at 1:40

GoogleCodeExporter commented 9 years ago
Great! Looking forward to the fix!

Original comment by willo_o...@jumio.com on 19 Aug 2013 at 8:06

GoogleCodeExporter commented 9 years ago
I tested compilation with Xcode, but I couldn't reproduce the problem.
Also, configure & make approach worked as well.

However, I'm not sure if my approach was right or not because I'm not familiar 
with Xcode.

First, I created a project.
Then, I copied lib/marisa.h and lib/marisa/ to the project directory.
After that, I added the source & header files to the project (with 
drag-and-drop).
And I could build a project successfully.

I would appreciate if you could tell me your steps to build your application.

By the way, I attached a special version that uses #include "marisa/stdio.h" 
instead of #include "stdio.h".
This version might solve your problem but it does not work with Visual C++.

Original comment by susumu.y...@gmail.com on 20 Aug 2013 at 5:46

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks - we'll look at that! Our problem probably was caused by using 
'recursive' include in Xcode. We didn't include the marisa files 'explicitly' 
but included a directory with a few subdirs. each subdir is an open source 
project - one of them marisa - then it happened for us ...

Original comment by willo_o...@jumio.com on 20 Aug 2013 at 3:06

GoogleCodeExporter commented 9 years ago
I'm happy to hear that the problem is solved.

In the future, I'll use non-standard include file names in order to avoid this 
kind of problems.

Original comment by susumu.y...@gmail.com on 21 Aug 2013 at 2:34

GoogleCodeExporter commented 9 years ago
Hi - sorry to be a bore - but why is this fixed? wouldn't it be great to always 
include "marisa/stdio.h" instead of "stdio.h" and adjust the visual studio 
build? 

Many thanks
Thomas

Original comment by willo_o...@jumio.com on 21 Aug 2013 at 10:16

GoogleCodeExporter commented 9 years ago
I'm sorry about being so late to reply.

I confirmed that VC++ can build libmarisa by adding "../../lib" to 
AdditionalIncludeDirectories and I committed a fixed version (r147).

Thank you.

Original comment by susumu.y...@gmail.com on 27 Aug 2013 at 12:16