JohnOne Posted February 21, 2012 Posted February 21, 2012 (edited) I'm having problems where autoit is crashing when calling a function in a dll file. I am trying to give the function optional parameters. From what I have read, it seems you can do it in much the same way as autoit. I have tried in a number of ways including //prototype //declaration void add(int i = 0); void add(int i = 0){ //stuff } void add(int i); void add(int i = 0){ //stuff } void add(int); void add(int i = 0){ //stuff } etc... in all cases I get a crash if I do not pass it something. Is there a specific way of achieving this for libraries, like overloading? EDIT: func is __stdcall if that makes any difference. Edited February 21, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Richard Robertson Posted February 21, 2012 Posted February 21, 2012 Optional parameters are not knowable at runtime. They are compile time constants ONLY. The reason they work in C++ when you include a header is because the header declares it so the compiler inserts it if you ignore it. If you are using a non-C++ language or not using the header which declares the default value, you must specify it like a normal parameter.
JohnOne Posted February 21, 2012 Author Posted February 21, 2012 (edited) Yes the prototype is in a header file, and I'mm using VC++ VS2010. AutoIt exits with -1073741819 Edited February 21, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
shanet Posted February 21, 2012 Posted February 21, 2012 JohnOne, it is my understanding that the prototype is where you declare defaults and the actual function does not have defaults. Eg:int main(int a = 42, char b = 'a'); /* Prototype */ int main(int a, char <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' /> { /* Function */ /* blah blah */ }In my (little) experience, this is the correct way to do this. [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
Shaggi Posted February 21, 2012 Posted February 21, 2012 (edited) Johnone, what you are trying to do is impossible. Optional parameters is only syntactic sugar resolved at compiletime as richard says. The function still expects the last parameter, hence you are corrupting the stack. Normally, when you have default parameters, you set them to 0 - and the called function recognizes this as a default parameters. Eg: void foo(int a, char * string) { if(!string) { // user called it like foo(5, NULL); //handle } else { //work with it } ... } Else you have to get into variadic functions, or passing an array of parameters and a count. E: I guess you could overload the functions, afaik _stdcall gets exported as _[name]@[parameters_in_bytes]. However, you would still have to choose the right one. JohnOne, it is my understanding that the prototype is where you declare defaults and the actual function does not have defaults. Eg: int main(int a = 42, char b = 'a'); /* Prototype */ int main(int a, char <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' /> { /* Function */ /* blah blah */ } In my (little) experience, this is the correct way to do this. You can also do it in the definition. Edited February 21, 2012 by Shaggi Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG
Richard Robertson Posted February 21, 2012 Posted February 21, 2012 Yes the prototype is in a header file, and I'mm using VC++ VS2010.AutoIt exits with -1073741819............................................________............................................................,.-‘”...................``~.,...............................................,.-”...................................“-.,.....................................,/...............................................”:,.............................,?......................................................,......................../...........................................................,}...................../......................................................,:`^`..}.................../...................................................,:”........./...................?.....__.........................................:`.........../................../__.(.....“~-,_..............................,:`........../.................../(_....”~,_........“~,_....................,:`........_/.....................{.._$;_......”=,_.......“-,_.......,.-~-,},.~”;/....}......................((.....*~_.......”=-._......“;,,./`..../”............../...............,,,___.`~,......“~.,....................`.....}............../.........................(....`=-,,.......`........................(......;_,,-”.........................../.`~,......`-...................................../................................`~.*-,.....................................|,./.....,__...........,,_..........}.>-._...................................|..............`=~-,.........`=~-,__......`,............................................................................`=~-,,.,......................................................................................`:,,...........................`..............__.......................................`=-,...................,%`>--==``..............................................._..........._,-%.......`..................................................,<`.._|_,-&``................`.............. funkey and Mat 2
Beege Posted February 21, 2012 Posted February 21, 2012 That was good.. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator
jchd Posted February 22, 2012 Posted February 22, 2012 No, Jave (wild guess). Good anyway! This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
JohnOne Posted February 22, 2012 Author Posted February 22, 2012 Cheers for the info gentlebodes. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now