May 06, 2024, 09:26:36 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


how determine build mode

Started by J B Wood (Zumwalt), May 12, 2006, 12:33:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J B Wood (Zumwalt)

Haven't found it yet, is there a #IF preprocessor directive?
Basically I need to do
#IF DEBUG
#use "mydll.dll"
#ELSE
#use "myreal.dll"
#ENDIF

J B Wood (Zumwalt)

#typedef BOOL int

Does not work on
import BOOL...

States syntax error - BOOL


Mike Stefanik

May 12, 2006, 01:11:21 PM #2 Last Edit: May 12, 2006, 01:18:40 PM by Mike Stefanik
There's #ifdef which will conditionally compile if a constant, type or structure is defined, but there's no #if that will evaluate expressions. So you'd use:

#ifdef DEBUG
// do whatever
#else
// do whatever
#endif

There's also an #ifndef to test if something isn't defined.

As far as the import, what are you trying to do there?

Edit: Ah, okay, I see. You're saying that if you define a type using #typedef, the compiler isn't reconignizing it whenever you specify it as a return type with import. Such as:

#typdef BOOL int
import BOOL MyFunction();

You're right, that looks like a bug.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

J B Wood (Zumwalt)

Thanks, I'll try the #ifdef again, here is another problem:

#use "dlls3impactd.lib"
import int i3ImpactSettings(ISETTINGS p0);
import void i3ImpactMain();
import void i3ImpactInitBegin();
import void i3ImpactInitEnd();
import void i3ImpactRunBegin();
import void i3ImpactRunEnd();
import void i3ImpactRender();
import void i3ImpactExitBegin();
import void i3ImpactExitEnd();
import void i3ImpactClose();
import int i3ImpactIsRendering();
import int i3ImpactIsActive();
import int i3ImpactIsReady();
import int i3ImpactIsExecuting();
import int i3ImpactIsInitializing();
import int i3ImpactIsSkippingRunPhase();
import int i3ImpactIsSkippingRenderPhase();
import int i3ImpactErrorFlag();
import void i3ImpactIsRenderingSet(int p0);
import void i3ImpactIsActiveSet(int p0);
import void i3ImpactIsReadySet(int p0);
import void i3ImpactIsExecutingSet(int p0);
import void i3ImpactIsInitializingSet(int p0);
import void i3ImpactIsSkippingRunPhaseSet(int p0);
import void i3ImpactIsSkippingRenderPhaseSet(int p0);
import void i3ImpactErrorFlagSet(int p0);
import void iProcessMessages();


error:
Compiling...
Aurora3ImpactApp.src

Linking...
Aurora Linker v1.0 Copyright ÂÃ,©2005 Ionic Wind Software
Unresolved external __imp_i3ImpactErrorFlagSet
Error: Unresolved extern __imp_i3ImpactErrorFlagSet
Error: Unresolved extern __imp_i3ImpactOpen
Error: Unresolved extern __imp_i3ImpactSettings
Error: Unresolved extern __imp_i3ImpactIsRendering
Error: Unresolved extern __imp_iProcessMessages
Error: Unresolved extern __imp_i3ImpactIsReady
Error: Unresolved extern __imp_i3ImpactIsActive
Error: Unresolved extern __imp_i3ImpactMain
Error: Unresolved extern __imp_i3ImpactIsExecuting
Error: Unresolved extern __imp_i3ImpactIsInitializing
Error: Unresolved extern __imp_i3ImpactInitBegin
Error: Unresolved extern __imp_i3ImpactErrorFlag
Error: Unresolved extern __imp_i3ImpactInitEnd
Error: Unresolved extern __imp_i3ImpactIsSkippingRunPhase
Error: Unresolved extern __imp_i3ImpactRunBegin
Error: Unresolved extern __imp_i3ImpactRunEnd
Error: Unresolved extern __imp_i3ImpactIsSkippingRenderPhase
Error: Unresolved extern __imp_i3ImpactRender
Error: Unresolved extern __imp_i3ImpactClose
Error(s) in linking Aurora3Impact.exe


I have tried declare and declare cdecl at the begining, those do not support additional output parameters: I have tried all of this below:

declare import, int i3ImpactSettings(ISETTINGS p0);
declare cdecl import, int i3ImpactSettings(ISETTINGS p0);
declare stdcall import, int i3ImpactSettings(ISETTINGS p0);

declare import int i3ImpactSettings(ISETTINGS p0);
declare cdecl import int i3ImpactSettings(ISETTINGS p0);
declare stdcall import int i3ImpactSettings(ISETTINGS p0);


Any other suggestions?

Mike Stefanik

Did you use the Tools | Create Import Library option to create the import library from the DLL that you're using?
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

J B Wood (Zumwalt)

Yes I did. It created a .lib file and placed it in the library folder.
Another issue I am having is int > string, meaning I have  return value that is an integer, and I want to display it to the console window, well, you can't just use
int myint;
myint=1;
writeln (myint);

you get illegal operand.
I have a function that returns a value, since there is no step through in debug, or step into, I can't see the value.

J B Wood (Zumwalt)

Question, does the dll have to be in the library folder or can it just be in the project folder?

Mike Stefanik

If you're using an import library, then you'd just use declare, as:

#use "mylibrary.lib"
declare import, MyFunction(int param1, int param2), int;

The problem with your declarations is that you're specifying the return type in the wrong place. It goes at the end of the function, not the beginning like it does in C/C++.

As far as the integer being passed to writeln() you either need to convert it to a string using NumToStr() or use print() or sprint(). In other words:

int nValue = 1;
print("My value is ", nValue);
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Mike Stefanik

The DLL itself just needs to be somewhere the standard Windows search rules can find it (ie: the application directory, current working directory, a directory specified in the PATH environment variable or the windows and system32 directories).
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

J B Wood (Zumwalt)

May 12, 2006, 02:48:44 PM #9 Last Edit: May 12, 2006, 02:53:27 PM by zumwalt
Its moving forward, if I get the initial screens to show up (as in rendered), I'll post the images as to what I am up to.
So far, it appears to have the same caviots that vb.net has on its pickyness.
I am running into a false access violation, this occurs when you have a return type but you are not handling the return.
For instance, some of my functions return a boolean, well, since the smallest value is a word, I have to use a literal 'catch', although my IF statements are C# based, they are assuming it is true or false, I have to put in the full conditional logic.

Anyway, more questions in a bit, I am down to line 415 in my code and have it debugged that far.

How do you use byref and byval in Aurora?
I need to pass in a structure into a function as ref, myfunction(ref myitem);

Ionic Wind Support Team

Structures are passed by reference as default.  You only need to use BYVAL if you want to override the default.
Ionic Wind Support Team

J B Wood (Zumwalt)

#typedef BOOL int
declare import, i3ImpactSettings(ISETTINGS p0),int;

ISETTINGS is a structure in the code as:
struct ISETTINGS
{
   UINT dwAdapter;
   UINT dwDevice;
   UINT dwMode;
   UINT MultiSampleType;
   BOOL bFullScreen;
   BOOL bDoNotShow;
}

Now, the call gives me a problem:

ISETTINGS settings;
settings.dwAdapter=1024;
settings.dwDevice=768;
settings.MultiSampleType=32;
settings.bFullScreen=0;
settings.bDoNotShow=1;

int ret1;
ret1=i3ImpactSettings(settings);

Starting debug session...
...
First chance exception: Address 0x10012653 Access Violation.
Final chance exception: Address 0x10012653 Access Violation.


I only get this error from Aurora if I am passing the wrong values into my functions.
In this case, I need to pass settings into it, and the return is technically a boolean.

Ionic Wind Support Team

BOOL and INT are the same thing.  32 bits in size and returned in eax anyway.  The return value is probably not causing your problem.  Macke sure it is a STDCALL function in the DLL.  Otherwise change your call to CDECL.

UINT needs to be defined somewhere.  Aurora uses basic instrinsic types. 

#typedef UINT unsigned int

Let me see the C declaration for it and I'll convert it for you.
Ionic Wind Support Team

J B Wood (Zumwalt)

This is the structure as written in C# that I need to convert.

[StructLayout(LayoutKind.Sequential)]
public struct iSettings
{
   public int dwAdapter;
   public int dwDevice;
   public int dwMode;
   public int MultiSampleType;
   public bool bFullScreen;
   public bool bDoNotShow;
   public iSettings(int width_ ,int height_,int bpp ,bool full, bool show)
   {
      dwAdapter = 0;
      dwDevice = 0;
      dwMode = width_ * height_ * bpp;
      MultiSampleType = 0;
      bFullScreen = full;
      bDoNotShow = show;
   }
}   

I was tying to shortcut it and just deal with the width, height, bpp, full screen and show, as the public iSettings is written.
I didn't know if Aurora supported nested constructors for the structure or not.
I have:
// define custom types
#typedef UINT unsigned int
#typedef HWND UINT
#typedef HANDLE UINT
#typedef BOOL int
#typedef CHAR byte
#typedef LONG int

As my custom types already. This is all pretty much straight forward at the moment on conversion between C#, C and Aurora.
The C equivelant of the same structure is:

struct ISETTINGS
{
   DWORD dwAdapter;
   DWORD dwDevice;
   DWORD dwMode;
   DWORD MultiSampleType;
   BOOL bFullScreen;
   BOOL bDoNotShow;
};

When called:
ISETTINGS iSettings = {0,0,640*480*16,0,FALSE,FALSE};

Which gives me an idea.. I am probably over complicating what I need done.

J B Wood (Zumwalt)

Another bug: When debugging to many times, you eventually get:
Compiling...
Aurora3ImpactApp.src
No Errors

Linking...
Aurora Linker v1.0 Copyright ÂÃ,©2005 Ionic Wind Software
Generating C:\Program Files\Aurora\projects\Aurora3ImpactApp.exe
Error: Unable to open output file C:\Program Files\Aurora\projects\Aurora3ImpactApp.exe
Error(s) in linking C:\Program Files\Aurora\projects\Aurora3ImpactApp.exe


Just shut down aurora and restart it. for some reason, the last debug event didn't let go of the exe.

J B Wood (Zumwalt)

May 12, 2006, 03:39:11 PM #15 Last Edit: May 12, 2006, 03:41:05 PM by zumwalt
Well this was a fun day.. :)

J B Wood (Zumwalt)

Well if this thing doesn't drive me psychotic, I have pretty much learned alot in a short time with it. Now I have an initial entry port for 3impact written, and I will go back over the tutorials on how to use src and inc files properly with this compiler. I want to seperate out he entire import so that the user only will need 1 file to add to there project and use the functions.

I think those instructions are hiding around somewhere.
All the 3impact work I do in 1 file, and just use something like #include "file" or something.

Parker

In C# (and C++) a bool is a byte long, so you should be using Aurora's BYTE type. C++ isn't case sensitive, so the windows API defines BOOL to be an int, which can be confusing when converting.

J B Wood (Zumwalt)

Thanks, I'll take a look at that.
Also, although I can't seem to find this yet, if I have multiple src files, create a project, add the files to the project, are all of the src files intermingled? Meaning like public methods, so that I can give the src file to what I create, all they have to do is add it to there projects, and it just works?

Parker

See your other topic. Subroutines are not automatically global and descriptor data isn't exported as in java.