Re: [sqlite] What this function returns?

2013-11-29 Thread Harold Wood
Lol so call you igor?

-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of John McKown
Sent: Friday, November 29, 2013 8:10 PM
To: rsm...@rsweb.co.za; General Discussion of SQLite Database
Subject: Re: [sqlite] What this function returns?

Ah, found it.
http://msdn.microsoft.com/en-us/library/s3f49ktz.aspx

__int64, unsigned __int64, long long, unsigned long long,

-- 
> This is clearly another case of too many mad scientists, and not 
> enough hunchbacks.
>
> Maranatha! <><
> John McKown
>



--
This is clearly another case of too many mad scientists, and not enough
hunchbacks.

Maranatha! <><
John McKown
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] What this function returns?

2013-11-29 Thread John McKown
Ah, found it.
http://msdn.microsoft.com/en-us/library/s3f49ktz.aspx

__int64, unsigned __int64, long long, unsigned long long,

-- 
> This is clearly another case of too many mad scientists, and not enough
> hunchbacks.
>
> Maranatha! <><
> John McKown
>



-- 
This is clearly another case of too many mad scientists, and not enough
hunchbacks.

Maranatha! <><
John McKown
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] What this function returns?

2013-11-29 Thread John McKown
On Fri, Nov 29, 2013 at 9:47 PM, RSmith  wrote:

>
> The fact that the app compiles is no great precursor to its success in the
> wild.  The thing you are avoiding is not a dependancy - 64 bit types should
> be easy in any platform and I know Windows (anything after XP anyway) uses
> only 64-bit internals, much like any other OS since the dawn of the 21st
> century.  The fact that you can still compile 32 bit programs and run it is
> pure backward compatibility on any system that still allow it, so if your
> compiler does not support it natively, you need to upgrade.
>
> But, that is not the case... your compiler supports it just fine - it
> isn't a dependancy, it's a native part of the compiler, it must be.  Even
> in older 32-bit compiling systems there's always a 64 bit LongLong or Int64
> or whatever flavour it went by. The reason you might not be getting the
> same 32-vs-64 bit warning might be that your compiler is sneakily using 64
> bit integers in the background anyway, while the other doesn't or at least,
> doesn't warn you about it. (This is a hypothesis, I'm not using MSVC so
> cannot say for sure).
>
> Either way, you NEED to cast that return value to a proper data-type hat
> can hold all of 64 bits in it... else you will get errors, especially when
> some user of your program runs into the first >32bit number in his/her
> database and it turns negative, or overwrite previous keys, etc. etc.
>
> You cannot ignore it, but it should be really easy to fix. Any MSVC buff
> here knows the exact Type for a 64b-int in MSVC?
>

I don't _do_ Windows, but a fast search gave me:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383710%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384264%28v=vs.85%29.aspx

__int64, DWORD64 (unsigned), INT64 (signed), LONG64 (signed), UINT64
(unsigned), ULONG64 (unsigned), but the MSVC documentation seems to only
list "signed long int" and "unsigned long int". As best as I can find.

Personally, I would use the sqlite3 supplied name and let Dr. Hipp's code
resolve it to the proper declaration based on the compiler being used.


-- 
This is clearly another case of too many mad scientists, and not enough
hunchbacks.

Maranatha! <><
John McKown
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] What this function returns?

2013-11-29 Thread RSmith


On 2013/11/30 05:28, Igor Korot wrote:

As you can see from http://sqlite.org/c3ref/last_insert_rowid.html, it
returns sqlite3_int64, a signed 64-bit integer type.  The C99 name and
I think the C++11 name for this is int64_t, which is probably what
you want, but I vaguely recall the Microsoft compiler requires jumping
through some kind of hoop to get it.  You could just use sqlite3_int64
directly if you don't mind taking the header dependency.
Well, than I don't want the extra dependancy.
I have a nice application with dependancies set up correctly as it is
compiled on Windows.
And I wouldn't even know about it if it's not about Mac compilation. ;-)

My biggest problem is: why MSVC compiled this code just fine?

Also I am compiling 32-bit app on both platforms.


The fact that the app compiles is no great precursor to its success in the wild.  The thing you are avoiding is not a dependancy - 
64 bit types should be easy in any platform and I know Windows (anything after XP anyway) uses only 64-bit internals, much like any 
other OS since the dawn of the 21st century.  The fact that you can still compile 32 bit programs and run it is pure backward 
compatibility on any system that still allow it, so if your compiler does not support it natively, you need to upgrade.


But, that is not the case... your compiler supports it just fine - it isn't a dependancy, it's a native part of the compiler, it 
must be.  Even in older 32-bit compiling systems there's always a 64 bit LongLong or Int64 or whatever flavour it went by. The 
reason you might not be getting the same 32-vs-64 bit warning might be that your compiler is sneakily using 64 bit integers in the 
background anyway, while the other doesn't or at least, doesn't warn you about it. (This is a hypothesis, I'm not using MSVC so 
cannot say for sure).


Either way, you NEED to cast that return value to a proper data-type hat can hold all of 64 bits in it... else you will get errors, 
especially when some user of your program runs into the first >32bit number in his/her database and it turns negative, or overwrite 
previous keys, etc. etc.


You cannot ignore it, but it should be really easy to fix. Any MSVC buff here 
knows the exact Type for a 64b-int in MSVC?



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] What this function returns?

2013-11-29 Thread Igor Korot
Simon,

On Fri, Nov 29, 2013 at 7:33 PM, Simon Slavin  wrote:
>
> On 30 Nov 2013, at 3:28am, Igor Korot  wrote:
>
>> Also I am compiling 32-bit app on both platforms.
>
> Do you absolutely need to compile 32-bit for Macs ?  There are almost no Macs 
> which can't handle 64-bit left, and 64-bit apps are faster and mode 
> compatible with everything else used these days.
>
> I have no experience of trying to develop the same app for Windows & Mac, so 
> if that's a good reason to compile for 32-bit please excuse me.

I will eventually compile 64-bit app on both platforms, but right now
for at least testing purposes
I am doing everything 32-bit.

Thank you.

>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] What this function returns?

2013-11-29 Thread Simon Slavin

On 30 Nov 2013, at 3:28am, Igor Korot  wrote:

> Also I am compiling 32-bit app on both platforms.

Do you absolutely need to compile 32-bit for Macs ?  There are almost no Macs 
which can't handle 64-bit left, and 64-bit apps are faster and mode compatible 
with everything else used these days.

I have no experience of trying to develop the same app for Windows & Mac, so if 
that's a good reason to compile for 32-bit please excuse me.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] What this function returns?

2013-11-29 Thread Igor Korot
Drake,

On Fri, Nov 29, 2013 at 7:04 PM, Drake Wilson  wrote:
> Quoth Igor Korot , on 2013-11-29 18:49:05 -0800:
>> Trying to change the return type to long does not solve the warning.
>>
>> Which value should this function return?
>
> As you can see from http://sqlite.org/c3ref/last_insert_rowid.html, it
> returns sqlite3_int64, a signed 64-bit integer type.  The C99 name and
> I think the C++11 name for this is int64_t, which is probably what
> you want, but I vaguely recall the Microsoft compiler requires jumping
> through some kind of hoop to get it.  You could just use sqlite3_int64
> directly if you don't mind taking the header dependency.

Well, than I don't want the extra dependancy.
I have a nice application with dependancies set up correctly as it is
compiled on Windows.
And I wouldn't even know about it if it's not about Mac compilation. ;-)

My biggest problem is: why MSVC compiled this code just fine?

Also I am compiling 32-bit app on both platforms.

>
> The truncation is actually a potential error: e.g., a row ID of 2^32
> would be returned as 0 instead on a system with 32-bit int.  It's the
> sort of thing you might not see in production for a while until it
> breaks everything suddenly a ways down the line.

Yes, thats why I am trying to solve it.

Thank you.

>
>---> Drake Wilson
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] What this function returns?

2013-11-29 Thread Drake Wilson
Quoth Igor Korot , on 2013-11-29 18:49:05 -0800:
> Trying to change the return type to long does not solve the warning.
> 
> Which value should this function return?

As you can see from http://sqlite.org/c3ref/last_insert_rowid.html, it
returns sqlite3_int64, a signed 64-bit integer type.  The C99 name and
I think the C++11 name for this is int64_t, which is probably what
you want, but I vaguely recall the Microsoft compiler requires jumping
through some kind of hoop to get it.  You could just use sqlite3_int64
directly if you don't mind taking the header dependency.

The truncation is actually a potential error: e.g., a row ID of 2^32
would be returned as 0 instead on a system with 32-bit int.  It's the
sort of thing you might not see in production for a while until it
breaks everything suddenly a ways down the line.

   ---> Drake Wilson
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] What this function returns?

2013-11-29 Thread Igor Korot
Hi, ALL,
One stupid question: what sqlite3_last_insert_rowid() function returns?

I have the following code:

int MyClass::Foo()
{
   return sqlite3_last_insert_rowid( m_handle );
}

It compiles fine on Windows (7 64 bit) with MSVC 2010 SP1 Pro 32-bit project.
But on Snow Leopard XCode 4.2 32-bit project Cocoa it produces:

"Implicit conversion shortens 64-bit value to 32-bit"

Trying to change the return type to long does not solve the warning.

Which value should this function return?

Thank you.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users