Ah, understood.

I thought you had a struct or a class named Mem.


then short term solution is to rename Mem in sqlite.h

using the #define directive + include file should do the trick.

as they say solve it by using a level of indirection!

It will be a bit ugly, but until
a) sqlite change the name
or
b) you change the namespace name

you'll be stuck with a hack!

Cordialement!

Daniel


2017-04-10 5:11 GMT-04:00 dip <x...@protonmail.com>:

> I am mixing C and C++ code. My code is in C++, SQLite is in C.
> Just create memory.h:
>
> namespace Mem {
> // some functions
> }
>
> And create code.cpp:
>
> #include "memory.h"
> #include "sqlite3.h"
>
> void Func()
> {
> Mem::SomeFunc(); // gives the compilation error
> }
>
> Sent with [ProtonMail](https://protonmail.com) Secure Email.
>
> -------- Original Message --------
> Subject: Re: [sqlite] "struct Mem" conflicts with namespaces/classes
> having the same name
> Local Time: April 10, 2017 2:29 AM
> UTC Time: April 9, 2017 11:29 PM
> From: woni...@gmail.com
> To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
>
> I see no problems with C++.
>
> Mem is only foward declared, you can redefined it to whatever you want. as
> long as you do not redefined it for sqlite.c you should be good.
>
> in sqlite.h it's declared:
>
> struct Mem;
>
> so in your code if you do:
>
> struct Mem { int a;int b;} then your definition will be used for your code.
>
> as sqlite is only using pointer, and has his own definition, I do not see
> the problem.
>
> it breaks the ODR, but as I previously said it's used/allocated internally
> by sqlite which should never see your definition.
>
> can you explain in more detail what is happening ?
>
> can you make a small reproduceable sample ?
>
> also are you mixing C++ & C, or is your code all in c ?
>
> Daniel
>
> 2017-04-09 15:49 GMT-04:00 dip <x...@protonmail.com>:
>
> > sqlite3.c is C file. C does not support namespaces.
> > Even though another project files are .cpp, sqlite3.c is still compiled
> as
> > C language source.
> > Therefore, no ability to use "using namespace" in sqlite3.c.
> > Also, "using namespace" does not actually put functions in the source in
> > namespace. It just helps it find another functions without specifying
> > namespace name.
> >
> > Sent with [ProtonMail](https://protonmail.com) Secure Email.
> >
> > -------- Original Message --------
> > Subject: Re: [sqlite] "struct Mem" conflicts with namespaces/classes
> > having the same name
> > Local Time: April 9, 2017 10:23 PM
> > UTC Time: April 9, 2017 7:23 PM
> > From: d3c...@gmail.com
> > To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
> >
> > On Sun, Apr 9, 2017 at 12:20 PM, Richard Damon <rich...@damon-family.org
> >
> > wrote:
> >
> > > On 4/9/17 1:49 PM, Olivier Mascia wrote:
> > >
> > >> Le 9 avr. 2017 à 18:49, dip <x...@protonmail.com> a écrit :
> > >>>
> > >>> I downloaded latest SQLite Amalgamation (v 3.18.0) to embed it in my
> > >>> project.
> > >>> After that I got a lot of errors while compiling (compiler is
> Microsoft
> > >>> Visual Studio 2017).
> > >>> Errors were caused by the following line in sqlite3.h:
> > >>>
> > >>> typedef struct Mem sqlite3_value;
> > >>>
> > >>> The reason is that I have the namespace with the same name.
> > >>> So I have a suggestion to rename "struct Mem" to something else (add
> > >>> prefix to it) because "Mem" is a very common name like "input" or
> > "data" or
> > >>> "buffer" and there may be classes or namespaces having the same name.
> > >>>
> > >> The way to overcome this completely in large programmings using many
> > >> libraries is to include sqlite3.h within a namespace. Not something
> that
> > >> SQLite code must do itself: that's best handled at the user project
> > level.
> > >>
> > >> The problem with this is that if the header file is put in a namespace
> > in
> > > the user code, then the source file that defines these functions needs
> to
> > > also be changed to put the files in that same namespace, or the things
> > > being defined won't be found.
> > >
> > > think that's what 'use namespace' is for
> >
> > > --
> > > Richard Damon
> > >
> > >
> > > _______________________________________________
> > > sqlite-users mailing list
> > > sqlite-users@mailinglists.sqlite.org
> > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> > >
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users@mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users@mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
>
> --
> Daniel
> *L'action accède à la perfection quand, bien que vivant, vous êtes déjà
> mort*
> *Bunan*
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Daniel
*L'action accède à la perfection quand, bien que vivant, vous êtes déjà
mort*
*Bunan*
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to