OCAU group project?

Discussion in 'Programming & Software Development' started by Aamdaron, Nov 2, 2003.

  1. Deltoid

    Deltoid Member

    Joined:
    May 24, 2003
    Messages:
    9,515
    Location:
    Brisbane
    yeh its linix emu but will make an .exe
     
  2. LINUX

    LINUX Member

    Joined:
    Sep 18, 2001
    Messages:
    3,062
    Location:
    Dudley, Newcastle
    i'm just wondering how gcc under cygwin would be able to make a windows GUI without using gtk/qt/etc. is it possible to code a windows native GUI through cigwin?
     
  3. OP
    OP
    Aamdaron

    Aamdaron Member

    Joined:
    Jul 25, 2002
    Messages:
    2,113
    Location:
    Melbourne
    you can use the window.h header or we could try opengl :D
     
  4. MadOnion87

    MadOnion87 Member

    Joined:
    Jul 10, 2002
    Messages:
    3,232
    Location:
    Old Trafford, Manchester
    but does it offer same performance as windows native?
     
  5. Deltoid

    Deltoid Member

    Joined:
    May 24, 2003
    Messages:
    9,515
    Location:
    Brisbane
    not sure. I normally just make stuff which runs on linux.

    So cant say.

    Might be a good idea going for a native windows one.

    Ive never compiled anything that big with cygwin so dunno how it affect performanc
     
  6. Buzzard

    Buzzard Member

    Joined:
    Apr 10, 2002
    Messages:
    758
    Location:
    Dandenong
    Cygwin is a Linux enviroment + tools for Windows which includes GCC (MinGW also has a Windows version of GCC)

    GCC (Cygwin/MinGW) will create programs desgined to run in windows (without any emulation, though IIRC cygwin compiled binaries require a cygwin dll). GCC is a reasonable good compiler (IIRC better than Borlands, about on par with MS, and miles away from Intel. Based on compile time and run time). GCC is used to compile the linux kernel so I think it can manage a small stress testing program :)

    You could write a GUI using pure C(++) (no MFC, VLC, CLX, ActiveX, WxWindows, etc...) but its much easier using windowing library (this includes VB etc..)
     
  7. LINUX

    LINUX Member

    Joined:
    Sep 18, 2001
    Messages:
    3,062
    Location:
    Dudley, Newcastle
    woot! 1 exam down so next thursday i'll be good to start working more seriously on this thing.

    the hardest thing about this project is going to be working on it for more than a day or two :p. that's about the average amount of time i've spent on the same project. the difference is that this time i'll have more of a goal: build something usefull rather than just satisfy an itch.

    i can see myself wandering off and trying to build another neural network simulator or something :p, currently i have this plan to build a mathematical model of a walker (mech type thing) and write a genetic algorithm to make it learn how to walk.
     
    Last edited: Nov 12, 2003
  8. MadOnion87

    MadOnion87 Member

    Joined:
    Jul 10, 2002
    Messages:
    3,232
    Location:
    Old Trafford, Manchester
    any difference on the final .exe between Cygwin and MS?
    (eg. like does it require any .dll to run like VB needs VB6.dll or something to run)
     
  9. Buzzard

    Buzzard Member

    Joined:
    Apr 10, 2002
    Messages:
    758
    Location:
    Dandenong
    The actual exes wont be identical, but the execution will be (they'll do the same thing in different ways). I believe that the cygwin version of GCC requires a dll, while the MinGW version doesn't (it also has less restricting license)
     
  10. Buzzard

    Buzzard Member

    Joined:
    Apr 10, 2002
    Messages:
    758
    Location:
    Dandenong
    Where has everybody gone ? :)

    Borland Builder X Personal Edition (appears to be free for non profit use), as well as being cross platform ( the IDE is written in java :eek: ) is able to use (and comes with) MinGW GCC, and the command line Borland compiler. If anyone is looking for an v.impressive alternative to DevC++ (or notepad :)) its avaliable at for download at Borland.com (it is >300MB though.....)

    hehe, the most complicated program I've written is a log file parser :)

    Opensource is going to quite interesting, how can anyone trust the results from a program that can modified and re-compiled by anyone ?

    I wrote a simple program for reading values from an ini file this afternoon... And since it has been years since I did any standard C++ programming, does anyone want to have a look at the source and telling me all the stupid things I did ? :)
     
  11. MadOnion87

    MadOnion87 Member

    Joined:
    Jul 10, 2002
    Messages:
    3,232
    Location:
    Old Trafford, Manchester
    well i think we better agree on a compiler
    or we might just build .lib and use them?
     
  12. LINUX

    LINUX Member

    Joined:
    Sep 18, 2001
    Messages:
    3,062
    Location:
    Dudley, Newcastle
    uh...do you wanna like, tell us where this .ini reader is so it's possible for us to comment on it?
     
  13. Buzzard

    Buzzard Member

    Joined:
    Apr 10, 2002
    Messages:
    758
    Location:
    Dandenong
    Well I spose I should do that :) I should metion that it doesn't really read proper ini files, as it ignores setctions (ie. '[main]')
     
    Last edited: Nov 14, 2003
  14. LINUX

    LINUX Member

    Joined:
    Sep 18, 2001
    Messages:
    3,062
    Location:
    Dudley, Newcastle
    this part:

    // FIXME? - I dont think this should work.....
    // returning a pointer of a static string ?

    i believe should just work as you expect it. it's quite alright to return a pointer to a char, although since pointers tend to be more than 1 byte it's probably more efficient to just return the char itself :p. In the case of an array it's better to pass a pointer around (especially if it's a big one). if you pass an array to a function the compiler allocates extra stack space for it and it takes up more RAM.
     
  15. Buzzard

    Buzzard Member

    Joined:
    Apr 10, 2002
    Messages:
    758
    Location:
    Dandenong
    Forgive me, but I n00b when it comes to pointers..... The function returns the memory location of a string (an array of chars), but after the function exits why doesn't string get de-allocated (and thus the pointer pointing to some random data in memory) ?
     
  16. MadOnion87

    MadOnion87 Member

    Joined:
    Jul 10, 2002
    Messages:
    3,232
    Location:
    Old Trafford, Manchester
    i didn't read through your code but that really depends where you created your string, if its made by a new statement then i think its still there (i'm a noob in pointers too, hardly use them ;))
     
  17. LINUX

    LINUX Member

    Joined:
    Sep 18, 2001
    Messages:
    3,062
    Location:
    Dudley, Newcastle
    heh, who *isn't* a pointer n00b :p
     
  18. systemdown

    systemdown Member

    Joined:
    Oct 14, 2003
    Messages:
    716
    Location:
    Brisbane 4107
    When a variable is declared static in a function, it is instantiated on first use. Subsequent calls to the function will not reallocate memory for the variable. When you return a pointer to this variable, then the pointer is valid for the entire duration of your running program - declaring something 'static' like this explicitly tells the runtime environment to not deallocate it off the stack when the function returns.

    Yes, objects/variables declared using the 'new' operator are allocated on the heap - not on the stack. Of course, if you don't later call 'delete' on it, then that memory will not be freed until the program exits and is cleaned up. Similarly, losing a pointer to this memory will effectively render that particular chunk of memory lost (ie. memory leak). Of course, with desktop machines having at least 256mb these days, it's unlikely that losing 4 bytes here or 8 bytes there will be a problem - but that's not why we manage our memory, we do it because it's good programming practice.

    EDIT: I just read your code Buzzard, you aren't doing anything wrong by returning a char* - the char array is copied first. Also, you didn't declare the char array 'static', so that 1024 bytes is being allocated on the stack each call to the function - it'd be more efficient if you used 'static', although you'd have to clear the char array before using it each time.
     
    Last edited: Nov 15, 2003
  19. Buzzard

    Buzzard Member

    Joined:
    Apr 10, 2002
    Messages:
    758
    Location:
    Dandenong
    Its all starting to make sense now, thanks for that very informative post systemdown.

    -Buzzard
     
  20. Buzzard

    Buzzard Member

    Joined:
    Apr 10, 2002
    Messages:
    758
    Location:
    Dandenong
    Hmmm, I thought I understood what was going on.... It appears not :)

    Sorry if this is a little OT....

    PHP:
    #include <iostream>
    using namespace std;

    char *returnSomethingchar *strValue )
    {
        
    char readValue[1024];
        
    strcpyreadValuestrValue );
        return 
    readValue;
    }

    char *returnSomething2char *strValue )
    {
        static 
    char readValue[1024];
        
    strcpyreadValuestrValue );
        return 
    readValue;
    }

    int mainvoid )
    {
        
    char *string1, *string2, *string3, *string4;

        
    string1 returnSomething"abc" );
        
    string2 returnSomething"def" );

        
    string3 returnSomething2"123" );
        
    string4 returnSomething2"456" );

        
    cout << "String 1: " << string1 << endl;
        
    cout << "String 2: " << string2 << endl;
        
    cout << "String 3: " << string3 << endl;
        
    cout << "String 4: " << string4 << endl;

        return 
    0;
    }

    Now the output it:
    PHP:
    String 1def
    String 2
    def
    String 3
    456
    String 4
    456
    Why isn't it:
    PHP:
    String 1abc
    String 2
    def
    String 3
    456
    String 4
    456
     

Share This Page

Advertisement: