Newbie Developer Forum

This forum will be closed shortly. Please post all development related questions and/or discussion on the Haiku Development, or Haiku 3rd party Development mailing lists.

Newbie Question

Forum thread started by leaf on Sun, 2009-02-22 13:20

Hi,
I know that this section is going to be closed but the question is pretty basic and this is more or less the first time I'm coding applications in C++ so I thought it's better I ask here.

I'm running Haiku under VMWare and I tried to compile the first example from "Programming the Be Operating System":

#include <Window.h>
#include <Application.h>
class SimpleWindow: public BWindow {
public:
SimpleWindow( BRect frame );
virtual bool QuitRequested();
};
 
SimpleWindow::SimpleWindow( BRect frame )
 : BWindow( frame, "A Simple Window", B_TITLED_WINDOW, B_NOT_RESIZABLE ) {
}
 
bool SimpleWindow::QuitRequested() {
 be_app->PostMessage( B_QUIT_REQUESTED );
 return true;
}
 
class SimpleApplication: public BApplication {
 public:
 SimpleApplication();
};
 
SimpleApplication::SimpleApplication()
: BApplication( "application/x-vnd.dps-simpleapp" ) {
 SimpleWindow *aWindow;
 BRect aRect;
 aRect.Set( 20, 20, 200, 60 );
 aWindow = new SimpleWindow( aRect );
 aWindow->Show();
}
 
main() {
  SimpleApplication myApplication;
  myApplication.Run();
  return 0;
}

When I compiled it under g++, it showed error messages about undefined references. Can anyone tell me what went wrong? Am I to add compiler flags or so?

EDIT: I copy-pasted the code wrongly so fixed it..

Guidelines for memory management and avoiding leaks?

Forum thread started by scuro on Tue, 2008-12-16 13:34

I am wondering if there are any rules/good practices I should follow for avoiding memory leaks.
Now and then I am developing some useless app for R5/Haiku (which I never finish by the way :-)), and every time I encounter problems and questions concerning memory management.

Are there any rules for stack allocation vs heap allocation?
For instance when sending a message, is it better to allocate it on the stack:

BMessage msg(B_SOME_CONSTANT);
BMessenger->SendMessage(&msg);

or do I allocate it on the heap?

BMessage *msg = new BMessage(B_..);
BMessenger->SendMessage(msg);
delete msg;

Or doesn't this matter at all?

I am also wondering if objects like a BStringView make a copy of the data it's arguments make a reference to:

//Allocate them on the heap
char* name = "newbie";
char* title = "question";

//pass them to the stringview
BStringView(BRect(0,0,50,20), name, title);

//Is it allowed to delete them??
delete name;
delete title;

Is the above allowed, or do I need to preserve the allocated Strings?
If you're thinking why I am not trying it out; i'm at work and want to know now :-)

These questions may be a little too much about C++ in general, but I can imagine they are Beos/Haiku specific too.
Are there any facilities in the OS to assist in memory management?

New developers on Haiku

Forum thread started by AvansMI7SEA on Wed, 2008-12-10 08:33

Hi,

We are a group of 12 students from the Avans University of applied science, located at 's-Hertogenbosch, The Netherlands. This semester we are creating an Instant Messenger for Haiku supporting multiple protocols, like MSN, Google Talk and jabber.
Our focus is to create an application that is really going to be used. We want to achieve this by creating a nice, user friendly GUI.
Programming is done in C++ and we are going to incorporate different design patterns (at least 4).

Any tips are always welcome, so are questions. We would very much appreciate you participating!

Greetings, Avans group MI7SEa

Unittesting with CPPUnit

Forum thread started by AvansMI7SEA on Wed, 2008-12-10 08:14

For our Instant messenger project we would like to use CPPUnit for unit testing. After some research we found the haiku port of CPPUnit in the SVN repository.

At this point we would like to use CPPUnit to assert that some exceptions are thrown on invalid input.

According to the CPPUnit manual there should be an macro for this type of validation:
CPPUNIT_ASSERT_THROW(expression, ExceptionType)

However we can't seem to find/use this macro with the Haiku CPPUnit-port. Could someone point me in the right direction?

How to set the stack size for BeOS/Haiku threads

Forum thread started by Negr0 on Sat, 2008-11-22 00:38

Hi,

is it possible to set a stack size for an BeOS/Haiku thread? I think on something like: "int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);".

greetz
Robert S.

Porting: What does it entail and why is it so hard

Forum thread started by lexen on Thu, 2008-11-06 15:30

Hello, I am a big fan of Haiku because it's fast and it is looking at computing in a new way, but without a variety of good programs, it doesn't really have any use for me. If it had Audacity or Kdenlive I could use it for just recording or video editing, but it doesn't (to my knowledge). My question is: What does it take to port a program from linux or windows and what makes it so hard? There are programs that have "OS independent source code." Are they making that up, or can it really work on all OS's.

Please explain it in laymen's terms because I am still learning.

Thanks,
Lexen

Haiku Kernel Architecture Questions

Forum thread started by jrash on Tue, 2008-10-28 14:28

I can't seem to find any in-depth documentation on the Haiku kernel, other than that it was forked from NewOS and that it is very BeOS like. I am interested in how the kernel differs from the BeOS kernel and other kernels in general. I know that the network stack in integrated in the kernel, but do the other servers still run in user space? I have read that the BeOS kernel was not a real microkernel in the sense that some drivers ran in the kernel, is this the same with the Haiku kernel? How does the Haiku kernel perform compared to BeOS or a monolithic kernel like Linux or the BSD kernels?

If any of you guys could point me in the direction of some documentation that answers these questions it would be much appreciated.

Syndicate content