Bug: SQLITE_DEFAULT_LOOKASIDE does not compile without SQLITE_OMIT_COMPILEOPTION_DIAGS

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug: SQLITE_DEFAULT_LOOKASIDE does not compile without SQLITE_OMIT_COMPILEOPTION_DIAGS

Victor Costan
In a custom SQLite build, SQLITE_DEFAULT_LOOKASIDE results in compilation
errors, unless used with SQLITE_OMIT_COMPILEOPTION_DIAGS.

This is because src/ctime.c includes the following block:
#ifdef SQLITE_DEFAULT_LOOKASIDE
  "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
#endif

However, CTIMEOPT_VAL (defined in the same file) is a one-argument macro:
#define CTIMEOPT_VAL_(opt) #opt
#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)

I suspect that an easy fix would involve defining a 2-argument macro
as CTIMEOPT_VAL(arg1)
"," CTIMEOPT_VAL(arg2).

I hope this is useful,
    Victor
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Bug: SQLITE_DEFAULT_LOOKASIDE does not compile without SQLITE_OMIT_COMPILEOPTION_DIAGS

Dan Kennedy-4
On 07/22/2018 07:48 PM, Victor Costan wrote:

> In a custom SQLite build, SQLITE_DEFAULT_LOOKASIDE results in compilation
> errors, unless used with SQLITE_OMIT_COMPILEOPTION_DIAGS.
>
> This is because src/ctime.c includes the following block:
> #ifdef SQLITE_DEFAULT_LOOKASIDE
>   "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
> #endif
>
> However, CTIMEOPT_VAL (defined in the same file) is a one-argument macro:
> #define CTIMEOPT_VAL_(opt) #opt
> #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
>
> I suspect that an easy fix would involve defining a 2-argument macro
> as CTIMEOPT_VAL(arg1)
> "," CTIMEOPT_VAL(arg2).

Thanks for reporting this. Now fixed here:

   https://www.sqlite.org/src/info/1cc72845f92198f2

Dan.

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Bug: SQLITE_DEFAULT_LOOKASIDE does not compile without SQLITE_OMIT_COMPILEOPTION_DIAGS

Dominique Devienne
On Mon, Jul 23, 2018 at 12:57 PM Dan Kennedy <[hidden email]> wrote:

> On 07/22/2018 07:48 PM, Victor Costan wrote:
> > In a custom SQLite build, SQLITE_DEFAULT_LOOKASIDE results in compilation
> > errors, unless used with SQLITE_OMIT_COMPILEOPTION_DIAGS.
> >
> > This is because src/ctime.c includes the following block:
> > #ifdef SQLITE_DEFAULT_LOOKASIDE
> >   "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
> > #endif
> >
> > However, CTIMEOPT_VAL (defined in the same file) is a one-argument macro:
> > #define CTIMEOPT_VAL_(opt) #opt
> > #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
> >
> > I suspect that an easy fix would involve defining a 2-argument macro
> > as CTIMEOPT_VAL(arg1)
> > "," CTIMEOPT_VAL(arg2).
>
> Thanks for reporting this. Now fixed here:
>
>    https://www.sqlite.org/src/info/1cc72845f92198f2
>

The diff adds:

#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)

But don't you mean the below instead?

#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt, opt)

From https://gcc.gnu.org/onlinedocs/cpp/Macro-Arguments.html :
The number of arguments you give must match the number of parameters in the
macro definition

I'm not sure though, possible I missed something. --DD
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Bug: SQLITE_DEFAULT_LOOKASIDE does not compile without SQLITE_OMIT_COMPILEOPTION_DIAGS

Dan Kennedy-4
On 07/23/2018 06:36 PM, Dominique Devienne wrote:

> On Mon, Jul 23, 2018 at 12:57 PM Dan Kennedy <[hidden email]> wrote:
>
>> On 07/22/2018 07:48 PM, Victor Costan wrote:
>>> In a custom SQLite build, SQLITE_DEFAULT_LOOKASIDE results in compilation
>>> errors, unless used with SQLITE_OMIT_COMPILEOPTION_DIAGS.
>>>
>>> This is because src/ctime.c includes the following block:
>>> #ifdef SQLITE_DEFAULT_LOOKASIDE
>>>   "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
>>> #endif
>>>
>>> However, CTIMEOPT_VAL (defined in the same file) is a one-argument macro:
>>> #define CTIMEOPT_VAL_(opt) #opt
>>> #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
>>>
>>> I suspect that an easy fix would involve defining a 2-argument macro
>>> as CTIMEOPT_VAL(arg1)
>>> "," CTIMEOPT_VAL(arg2).
>>
>> Thanks for reporting this. Now fixed here:
>>
>>    https://www.sqlite.org/src/info/1cc72845f92198f2
>>
>
> The diff adds:
>
> #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
> #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
>
> But don't you mean the below instead?
>
> #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
> #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt, opt)


Thanks for reviewing. I acknowledge it is a bit iffy.

SQLITE_DEFAULT_LOOKASIDE should be defined as two comma-separated
integers. e.g.

   -DSQLITE_DEFAULT_LOOKASIDE="100,100"

So CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE) expands to:

   CTIMEOPT_VAL2_(100, 100)

and so it works. If anybody knows a better way to do this (I'm no
preprocessor expert!) that is ANSI-C compatible, I think we'd be happy
to change the code.

Dan.





>
> From https://gcc.gnu.org/onlinedocs/cpp/Macro-Arguments.html :
> The number of arguments you give must match the number of parameters in the
> macro definition
>
> I'm not sure though, possible I missed something. --DD
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Bug: SQLITE_DEFAULT_LOOKASIDE does not compile without SQLITE_OMIT_COMPILEOPTION_DIAGS

Dominique Devienne
On Mon, Jul 23, 2018 at 5:37 PM Dan Kennedy <[hidden email]> wrote:

> On 07/23/2018 06:36 PM, Dominique Devienne wrote:
> > On Mon, Jul 23, 2018 at 12:57 PM Dan Kennedy <[hidden email]>
> wrote:
> > The diff adds:
> >
> > #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
> > #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
> >
> > But don't you mean the below instead?
> >
> > #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
> > #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt, opt)
>
>
> Thanks for reviewing. I acknowledge it is a bit iffy.
>
> SQLITE_DEFAULT_LOOKASIDE should be defined as two comma-separated
> integers. e.g.
>
>    -DSQLITE_DEFAULT_LOOKASIDE="100,100"
>
> So CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE) expands to:
>
>    CTIMEOPT_VAL2_(100, 100)
>
> and so it works. If anybody knows a better way to do this (I'm no
> preprocessor expert!) that is ANSI-C compatible, I think we'd be happy
> to change the code.
>

I'm not either. And I knew I was missing something indeed. Thanks for
making it clear.
So whether the code builds fine depends on the define's value having the
correct format then.

That GNU cpp doc clearly states
"All arguments to a macro are completely macro-expanded before they are
substituted into the macro body"

And you correctly documented the format needed, I just didn't get it the
first time, that the define's value is "reparsed".
So all is fine, sorry for the noise. Your code doesn't need any changes.
--DD
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Bug: SQLITE_DEFAULT_LOOKASIDE does not compile without SQLITE_OMIT_COMPILEOPTION_DIAGS

Victor Costan
In reply to this post by Dan Kennedy-4
On Mon, Jul 23, 2018 at 3:57 AM Dan Kennedy <[hidden email]> wrote:

> On 07/22/2018 07:48 PM, Victor Costan wrote:
> > In a custom SQLite build, SQLITE_DEFAULT_LOOKASIDE results in compilation
> > errors, unless used with SQLITE_OMIT_COMPILEOPTION_DIAGS.
> >
> > This is because src/ctime.c includes the following block:
> > #ifdef SQLITE_DEFAULT_LOOKASIDE
> >   "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
> > #endif
> >
> > However, CTIMEOPT_VAL (defined in the same file) is a one-argument macro:
> > #define CTIMEOPT_VAL_(opt) #opt
> > #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
> >
> > I suspect that an easy fix would involve defining a 2-argument macro
> > as CTIMEOPT_VAL(arg1)
> > "," CTIMEOPT_VAL(arg2).
>
> Thanks for reporting this. Now fixed here:
>
>    https://www.sqlite.org/src/info/1cc72845f92198f2


Thank you very much for the quick fix, Dan!

    Victor
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users