Jump to content

_declspec dll calling


ptrex
 Share

Recommended Posts

Some question came up in the SQLite thread. I don't know what this means since I am not a C programmer.

But could any of you tell me something about this.

But ask the devs if _declspec dll calling could be made possible thru autoit then fbsl.dll would not be needed.

Here is the link :

_declspec dll calling

We are still trying to figure out how to integrate SQLite into AutoIT.

Thanks in advance

Link to comment
Share on other sites

The question makes no sense. The keyword __declspec doesn't specify a calling convention. In fact, other than looking at the source code, its impossible as far as I know to even know if a function uses one of the __declspec flags.

Link to comment
Share on other sites

The question makes no sense. The keyword __declspec doesn't specify a calling convention. In fact, other than looking at the source code, its impossible as far as I know to even know if a function uses one of the __declspec flags.

At least the docs say so.

the calling conventions of standard built DLL are __cdecl, not __stdcall (or WINAPI)...

Hey Valik.

Do you think its a good idea to recompile the dll using __stdcall (whatever it is if its no calling convention) ?

or would autoit still have problems with functions like this

int sqlite3_get_table(
  sqlite3*,           /* An open database */
  const char *sql,     /* SQL to be executed */
  char ***resultp,     /* Result written to a char *[]  that this points to */
  int *nrow,             /* Number of result rows written here */
  int *ncolumn,       /* Number of result columns written here */
  char **errmsg       /* Error msg written here */
);
void sqlite3_free_table(char **result);

i'm concerned about reading the result...

Edited by piccaso
CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

The keyword __declspec is not a calling convention nor does it control the calling convention.

To answer your question(s), it would be better if the DLL was built using __stdcall (WINAPI). The difference between the two is who is responsible for cleaning up the stack after a function call. If the function does not use __stdcall, the stack isn't cleaned up. This isn't a huge problem but still, it should be avoided if not necessary.

AutoIt should have no problem with any non-class exports from a DLL. It may require judicious use of DllStruct but it is do-able.

Link to comment
Share on other sites

Link to comment
Share on other sites

@picasso/valik

Hi is this code saying something to you. I found this in the documentation section on the SQLite home page.

Write Programs That Use SQLite
Below is a simple TCL program that demonstrates how to use the TCL interface to SQLite. The program executes the SQL statements given as the second argument on the database defined by the first argument. The commands to watch for are the sqlite3 command on line 7 which opens an SQLite database and creates a new TCL command named "db" to access that database, the invocation of the db command on line 8 to execute SQL commands against the database, and the closing of the database connection on the last line of the script.

#!/usr/bin/tclsh
if {$argc!=2} {
  puts stderr "Usage: %s DATABASE SQL-STATEMENT"
  exit 1
}
load /usr/lib/tclsqlite3.so Sqlite3
sqlite3 db [lindex $argv 0]
db eval [lindex $argv 1] x {
  foreach v $x(*) {
    puts "$v = $x($v)"
  }
  puts ""
}
db close

Below is a simple C program that demonstrates how to use the C/C++ interface to SQLite. The name of a database is given by the first argument and the second argument is one or more SQL statements to execute against the database. The function calls to pay attention to here are the call to sqlite3_open() on line 22 which opens the database, sqlite3_exec() on line 27 that executes SQL commands against the database, and sqlite3_close() on line 31 that closes the database connection.

#include <stdio.h>
#include <sqlite3.h>

static int callback(void *NotUsed, int argc, char **argv, char **azColName){
  int i;
  for(i=0; i<argc; i++){
    printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  }
  printf("\n");
  return 0;
}

int main(int argc, char **argv){
  sqlite3 *db;
  char *zErrMsg = 0;
  int rc;

  if( argc!=3 ){
    fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
    exit(1);
  }
  rc = sqlite3_open(argv[1], &db);
  if( rc ){
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    exit(1);
  }
  rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
  if( rc!=SQLITE_OK ){
    fprintf(stderr, "SQL error: %s\n", zErrMsg);
  }
  sqlite3_close(db);
  return 0;
}

There's lot' s of other C code on the site, but I am not able to read or understand any of this.

I hope this can help

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...