JohnOne Posted February 14, 2014 Posted February 14, 2014 Is it possible in some way to make parameters optional in an exported C++ win32 dll? Kind of (this does not work) int func(LPCTSTR param1, LPCTSTR param2 = L"param"){ //stuff return 0; } Or something similar, I know it's a long shot cause find find anything to suggest there is. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JohnOne Posted February 14, 2014 Author Posted February 14, 2014 Or perhaps be overloaded in some fashion I'm unaware of? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
GtaSpider Posted February 14, 2014 Posted February 14, 2014 Whats the matter? void func( int required, int optional = 0); Should work with C++ (not with C) www.AutoIt.de - Moderator of the German AutoIt Forum
JohnOne Posted February 14, 2014 Author Posted February 14, 2014 (edited) Does not work, crashes without error (Well OS error with option to close, wait or check online) when called from AutoIt. EDIT: That's fine for internal function but I've not been able to get it to work externally. Edited February 14, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
funkey Posted February 15, 2014 Posted February 15, 2014 Afaik you cannot use optional parameters in DLLs. This is because the C++ compiler handles the optional parameters at compile time. So if you compile a DLL there is no optional parameter possible. But you just can use AutoIt for using optional parameters in your UDF. JohnOne 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning.
JohnOne Posted February 17, 2014 Author Posted February 17, 2014 Thanks funkey, you must be correct. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
jaberwacky Posted February 18, 2014 Posted February 18, 2014 (edited) You could go with your overloaded function idea though. Come to think of it, there must be a better way. Didn't Jon do it somehow with DllCall? Edited February 18, 2014 by jaberwacky Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
JohnOne Posted February 18, 2014 Author Posted February 18, 2014 Cannot judge by native functions, because it's all handled in the interpreter. Closest I'm going to get is in my other dll thread. if (!param || !Param[0]){ //provide a default; } AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Richard Robertson Posted February 19, 2014 Posted February 19, 2014 The above is correct. Native functions do not have optional parameters. The headers may indicate default values which the precompiler stage will read and fill in right before compilation. Example void method(int parameter = 0) { } int main() { method(); return 0; } // becomes void method(int) { } int main() { method(0); return 0; }
trancexx Posted February 19, 2014 Posted February 19, 2014 I'm not sure what jaberwacky meant, but DllCall doesn't provide way to omit default parameters. ♡♡♡ . eMyvnE
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