Skip to content

Commit

Permalink
Improvements to the MSVC build. Fix harmless compiler warnings. Enabl…
Browse files Browse the repository at this point in the history
…e use of 'stdcall'.
  • Loading branch information
Joe Mistachkin committed Mar 21, 2015
1 parent 68f4a99 commit 6ebaa44
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 149 deletions.
380 changes: 244 additions & 136 deletions Makefile.msc

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion ext/fts3/fts3_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,10 @@ int sqlite3Fts3SegReaderNew(
** an array of pending terms by term. This occurs as part of flushing
** the contents of the pending-terms hash table to the database.
*/
static int fts3CompareElemByTerm(const void *lhs, const void *rhs){
static int SQLITE_CDECL fts3CompareElemByTerm(
const void *lhs,
const void *rhs
){
char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
Expand Down
4 changes: 2 additions & 2 deletions ext/fts3/tool/fts3view.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ static void showSegdirMap(sqlite3 *db, const char *zTab){
sqlite3_column_int64(pStmt,5));
printf(" root %9s\n", rtag);
if( iLEnd>iStart ){
sqlite3_int64 iLower, iPrev, iX;
sqlite3_int64 iLower, iPrev = 0, iX;
if( iLEnd+1<=iEnd ){
sqlite3_bind_int64(pStmt2, 1, iLEnd+1);
sqlite3_bind_int64(pStmt2, 2, iEnd);
Expand Down Expand Up @@ -548,7 +548,7 @@ static void decodeSegment(
const unsigned char *aData, /* Content to print */
int nData /* Number of bytes of content */
){
sqlite3_int64 iChild;
sqlite3_int64 iChild = 0;
sqlite3_int64 iPrefix;
sqlite3_int64 nTerm;
sqlite3_int64 n;
Expand Down
2 changes: 1 addition & 1 deletion mptest/mptest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ static void unrecognizedArguments(
exit(1);
}

int main(int argc, char **argv){
int SQLITE_CDECL main(int argc, char **argv){
const char *zClient;
int iClient;
int n, i;
Expand Down
10 changes: 5 additions & 5 deletions src/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,7 @@ static void import_append_char(ImportCtx *p, int c){
** EOF on end-of-file.
** + Report syntax errors on stderr
*/
static char *csv_read_one_field(ImportCtx *p){
static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){
int c;
int cSep = p->cColSep;
int rSep = p->cRowSep;
Expand Down Expand Up @@ -2217,7 +2217,7 @@ static char *csv_read_one_field(ImportCtx *p){
** EOF on end-of-file.
** + Report syntax errors on stderr
*/
static char *ascii_read_one_field(ImportCtx *p){
static char *SQLITE_CDECL ascii_read_one_field(ImportCtx *p){
int c;
int cSep = p->cColSep;
int rSep = p->cRowSep;
Expand Down Expand Up @@ -2911,8 +2911,8 @@ static int do_meta_command(char *zLine, ShellState *p){
int nSep; /* Number of bytes in p->colSeparator[] */
char *zSql; /* An SQL statement */
ImportCtx sCtx; /* Reader context */
char *(*xRead)(ImportCtx*); /* Procedure to read one value */
int (*xCloser)(FILE*); /* Procedure to close th3 connection */
char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
int (SQLITE_CDECL *xCloser)(FILE*); /* Func to close file */

if( nArg!=3 ){
fprintf(stderr, "Usage: .import FILE TABLE\n");
Expand Down Expand Up @@ -4354,7 +4354,7 @@ static char *cmdline_option_value(int argc, char **argv, int i){
return argv[i];
}

int main(int argc, char **argv){
int SQLITE_CDECL main(int argc, char **argv){
char *zErrMsg = 0;
ShellState data;
const char *zInitFile = 0;
Expand Down
7 changes: 7 additions & 0 deletions src/sqlite.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ extern "C" {
# define SQLITE_EXTERN extern
#endif

/*
** Add the ability to override 'cdecl'
*/
#ifndef SQLITE_CDECL
# define SQLITE_CDECL
#endif

/*
** These no-op macros are used in front of interfaces to mark those
** interfaces as either deprecated or experimental. New applications
Expand Down
67 changes: 64 additions & 3 deletions tool/build-all-msvc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ IF NOT DEFINED _AECHO (SET _AECHO=REM)
IF NOT DEFINED _CECHO (SET _CECHO=REM)
IF NOT DEFINED _VECHO (SET _VECHO=REM)

SET REDIRECT=^>
IF DEFINED __ECHO SET REDIRECT=^^^>

%_AECHO% Running %0 %*

REM SET DFLAGS=/L
Expand Down Expand Up @@ -420,11 +423,11 @@ FOR %%P IN (%PLATFORMS%) DO (
) ELSE (
REM
REM NOTE: Even when the cleaning step has been disabled, we still
REM need to remove the build output for the files we are
REM need to remove the build output for all the files we are
REM specifically wanting to build for each platform.
REM
%_AECHO% Cleaning final output files only...
%__ECHO% DEL /Q *.lo sqlite3.dll sqlite3.lib sqlite3.pdb
%_AECHO% Cleaning final core library output files only...
%__ECHO% DEL /Q *.lo sqlite3.dll sqlite3.lib sqlite3.pdb 2%REDIRECT% NUL
)

REM
Expand Down Expand Up @@ -476,6 +479,64 @@ FOR %%P IN (%PLATFORMS%) DO (
GOTO errors
)
)

REM
REM NOTE: If requested, also build the shell executable.
REM
IF DEFINED BUILD_ALL_SHELL (
REM
REM NOTE: If necessary, make sure any previous build output for the
REM shell executable is deleted.
REM
IF DEFINED NOCLEAN (
REM
REM NOTE: Even when the cleaning step has been disabled, we still
REM need to remove the build output for all the files we are
REM specifically wanting to build for each platform.
REM
%_AECHO% Cleaning final shell executable output files only...
%__ECHO% DEL /Q sqlite3.exe sqlite3sh.pdb 2%REDIRECT% NUL
)

REM
REM NOTE: Call NMAKE with the MSVC makefile to build the "sqlite3.exe"
REM binary. The x86 compiler will be used to compile the native
REM command line tools needed during the build process itself.
REM Also, disable looking for and/or linking to the native Tcl
REM runtime library.
REM
%__ECHO% %NMAKE_CMD% sqlite3.exe XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS%

IF ERRORLEVEL 1 (
ECHO Failed to build %%B "sqlite3.exe" for platform %%P.
GOTO errors
)

REM
REM NOTE: Copy the "sqlite3.exe" file to the appropriate directory
REM for the build and platform beneath the binary directory.
REM
%__ECHO% XCOPY sqlite3.exe "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS%

IF ERRORLEVEL 1 (
ECHO Failed to copy "sqlite3.exe" to "%BINARYDIRECTORY%\%%B\%%D\".
GOTO errors
)

REM
REM NOTE: Copy the "sqlite3sh.pdb" file to the appropriate directory
REM for the build and platform beneath the binary directory
REM unless we are prevented from doing so.
REM
IF NOT DEFINED NOSYMBOLS (
%__ECHO% XCOPY sqlite3sh.pdb "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS%

IF ERRORLEVEL 1 (
ECHO Failed to copy "sqlite3sh.pdb" to "%BINARYDIRECTORY%\%%B\%%D\".
GOTO errors
)
)
)
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion tool/showdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ static void decodeCell(
int szPgHdr, /* Size of the page header. 0 or 100 */
int ofst /* Cell begins at a[ofst] */
){
int i, j;
int i, j = 0;
int leftChild;
i64 k;
i64 nPayload;
Expand Down

0 comments on commit 6ebaa44

Please sign in to comment.