![]() ![]()
|
![]() |
![]() Release 4 Coding IssuesNecessary code changes to support the new binary format and developer tools.
How long will it take to move my Application from R3 to R4? Development EnvironmentTool locationWith the introduction of the EGCS tools a new location for tools was needed (/boot/apps/Metrowerks/ didn't seem like the best place anymore.) Now all development tools will be located in a sub-directory of /boot/develop/tools/. The tools that will ship with R4 will be located as follows: EGCS: /boot/develop/tools/gnupro/ (Intel Only) Metrowerks: /boot/develop/tools/Metrowerks/ (PowerPC Only) PackageBuilder: /boot/develop/tools/PackageBuilder/
Exporting Symbols #pragma export on/reset __declspec(dllexport) Export files listing all symbols to be exportedWith the move to ELF we have a new recommended method: _EXPORT. Simply add _EXPORT before a function or class declaration and your compiler will do the right thing. See below for examples.
Shared Libraries In R4 Intel and ELF you link against the run-time library itself, just like you do in PowerPC. This will require modification of most makefiles and BeIDE projects to link against the appropriate items.
Shared Library Location: /boot/develop/lib/x86/ /boot/develop/lib/ppc/Links to the run-time libraries and Be provided static libraries and objects are located in these folders.
Code ChangesRemove all #pragma options#pragmas are compiler specific and should not be used in your code. We have suggestions for cleaning up your code and replacing #pragmas with safety. These suggestions work on both PowerPC and Intel. #pragma once This is used to make sure that a given header file is only defined once in the compile process. You can get the equivalent functionality using #defines. Replace: /* MyHeader.h */ #pragma once /* definitions follow */ With: /* MyHeader.h */ #ifndef MY_HEADER_H #define MY_HEADER_H /* definitions follow */ #endifThis allows you to simply include the appropriate header file in any other file and the compiler will make sure it is only included once. #pragma unused Used to clear warnings from implementations of functions that do not use all of the parameters passed in. BeBuild.h defines a macro _UNUSED that will make the parameter invisible to the Metrowerks compiler to stop warnings. Replace: my_function(int32 foo, int32 blah) { #pragma unused blah; } With: my_function(int32 foo, int32 _UNUSED(blah)) { } #pragma export Used to specify that a symbol needs to be exported from a given binary. It can be replaced by the _EXPORT macro. Replace: #pragma export on int32 my_function(); #pragma export reset #pragma export on class my_class; #pragma export reset With: _EXPORT int32 my_function(); _EXPORT class my_class;
Including the Proper Headers Errors reported that might be a result of improperly included header files are:
Structure Definitions Replace: struct fig { int bar; char blat[]; }; With: struct fig { int bar; char blat[0]; };
Const variables Replace: char *foo; message->FindString("foo", &foo); With: const char *foo; message->FindString("foo", &foo); We Advise Against Using: char *foo; message->FindString("foo", (const char **)&foo);
BMessage::FindPointer() && BMessage::FindData() Replace: BMenuItem *item; message->FindPointer("item", &item); const node_ref *node; ssize_t numBytes; message->FindData("node", B_RAW_TYPE, &node, &numBytes); With: BMenuItem *item; message->FindPointer("item", (void **)&item); const node_ref *node; ssize_t numBytes; message->FindData("node", B_RAW_TYPE, (void **)&node, &numBytes);
inherited Replace: class foo { public: int32 my_function(); } class bar : public foo { public: int32 my_function(); } bar::my_function() { inherited::my_function() /* the rest of my code */ } With: class foo { public: int32 my_function(); } class bar : public foo { public: int32 my_function(); } bar::my_function() { foo::my_function() /* the rest of my code */ } Or class foo { public: int32 my_function(); } class bar : public foo { public: int32 my_function(); private: typedef foo _inherited; } bar::my_function() { _inherited::my_function() /* the rest of my code */ }
Back to the Switch
|
Copyright ©1999 Be, Inc. Be, BeOS, and the Be and BeOS logos are registered trademarks, and BeBox, BeWare, GeekPort are trademarks of Be, Inc. All other trademarks mentioned are the property of their respective owners. Comments about this site? Please write us at webmaster@be.com. Icons used herein are the property of Be Inc. All rights reserved.