Fixes that make Haiku build with gcc 4. Mainly out of the following

categories:
* Missing includes (like <stdlib.h> and <string.h>).
* Linking against $(TARGET_LIBSTDC++) instead of libstdc++.r4.so.
* Local variables shadowing parameters.
* Default parameters in function definitions (as opposed to function
  declarations).
* All C++ stuff (nothrow, map, set, vector, min, max,...) must be imported
  explicitly from the std:: namespace now.
* "new (sometype)[...]" must read "new sometype[...]", even if sometype is
  something like "const char *".
* __FUNCTION__ is no longer a string literal (but a string expression), i.e.
  'printf(__FUNCTION__ ": ...\n")' is invalid code.
* A type cast results in a non-lvalue. E.g. "(char *)buffer += bytes"
  is an invalid expression.
* "friend class SomeClass" only works when SomeClass is known before.
  Otherwise the an inner class with that name is considered as friend.
  gcc 4 is much pickier about scopes.
* gcc 4 is generally stricter with respect to type conversions in C.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14878 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2005-11-12 23:27:14 +00:00
parent bcf95670a2
commit 758b1d0e05
167 changed files with 497 additions and 304 deletions
+21 -21
View File
@@ -80,27 +80,27 @@
/* cpp kit */
/* -- <typeinfo> */
class _IMPEXP_ROOT bad_cast;
class _IMPEXP_ROOT bad_typeid;
class _IMPEXP_ROOT type_info;
/* -- <exception> */
class _IMPEXP_ROOT exception;
class _IMPEXP_ROOT bad_exception;
/* -- <new.h> */
class _IMPEXP_ROOT bad_alloc;
/* -- <mexcept.h> */
class _IMPEXP_ROOT logic_error;
class _IMPEXP_ROOT domain_error;
class _IMPEXP_ROOT invalid_argument;
class _IMPEXP_ROOT length_error;
class _IMPEXP_ROOT out_of_range;
class _IMPEXP_ROOT runtime_error;
class _IMPEXP_ROOT range_error;
class _IMPEXP_ROOT overflow_error;
// /* -- <typeinfo> */
// class _IMPEXP_ROOT bad_cast;
// class _IMPEXP_ROOT bad_typeid;
// class _IMPEXP_ROOT type_info;
//
// /* -- <exception> */
// class _IMPEXP_ROOT exception;
// class _IMPEXP_ROOT bad_exception;
//
// /* -- <new.h> */
// class _IMPEXP_ROOT bad_alloc;
//
// /* -- <mexcept.h> */
// class _IMPEXP_ROOT logic_error;
// class _IMPEXP_ROOT domain_error;
// class _IMPEXP_ROOT invalid_argument;
// class _IMPEXP_ROOT length_error;
// class _IMPEXP_ROOT out_of_range;
// class _IMPEXP_ROOT runtime_error;
// class _IMPEXP_ROOT range_error;
// class _IMPEXP_ROOT overflow_error;
/* support kit */
class _IMPEXP_BE BArchivable;
+3 -3
View File
@@ -9,11 +9,11 @@
#ifndef _MESSAGE_H
#define _MESSAGE_H
#include <BeBuild.h>
#include <OS.h>
#include <Rect.h>
#include <DataIO.h>
#include <Flattenable.h>
#include <Messenger.h>
#include <OS.h>
#include <Rect.h>
// for convenience
#include <AppDefs.h>
+3 -2
View File
@@ -77,12 +77,13 @@ public:
size_t inAttributeCount);
void * operator new(size_t size);
void * operator new(size_t size, const nothrow_t &) throw();
void * operator new(size_t size,
const std::nothrow_t &) throw();
void operator delete(void * ptr);
#if !__MWERKS__
// there's a bug in MWCC under R4.1 and earlier
void operator delete(void * ptr,
const nothrow_t &) throw();
const std::nothrow_t &) throw();
#endif
static status_t SetMemoryPoolSize(size_t in_poolSize);
+6
View File
@@ -57,6 +57,12 @@ operator==(const pattern& a, const pattern& b)
return (*(uint64*)a.data == *(uint64*)b.data);
}
inline bool
operator!=(const pattern& a, const pattern& b)
{
return !(a == b);
}
#endif // __cplusplus
extern _IMPEXP_BE const pattern B_SOLID_HIGH;
+1
View File
@@ -15,6 +15,7 @@ class BEntry;
struct entry_ref;
class _rep_data_;
class _TContainerViewFilter_;
class BShelf : public BHandler {
public:
+1 -1
View File
@@ -356,7 +356,7 @@ extern void debugger(const char *message);
to re-enable the default debugger pass a zero.
*/
extern const int disable_debugger(int state);
extern int disable_debugger(int state);
// TODO: Remove. Temporary debug helper.
extern void debug_printf(const char *format, ...)
+2 -2
View File
@@ -236,14 +236,14 @@ virtual status_t HandleMessage(
size_t size);
void * operator new(
size_t size,
const nothrow_t &) throw();
const std::nothrow_t &) throw();
void operator delete(
void * ptr);
#if !__MWERKS__
// there's a bug in MWCC under R4.1 and earlier
void operator delete(
void * ptr,
const nothrow_t &) throw();
const std::nothrow_t &) throw();
#endif
protected:
+3 -1
View File
@@ -12,7 +12,9 @@
class BSound;
class sound_error : public exception {
class _SoundPlayNode;
class sound_error : public std::exception {
const char * m_str_const;
public:
sound_error(const char * str);
+1 -1
View File
@@ -156,7 +156,7 @@ int sigismember(const sigset_t *set, int signo);
const char *strsignal(int sig);
const void set_signal_stack(void *ptr, size_t size);
void set_signal_stack(void *ptr, size_t size);
int sigaltstack(const stack_t *ss, stack_t *oss); /* XXXdbg */
extern inline int
+3
View File
@@ -30,6 +30,7 @@
#include <MessageField.h>
// Standard Includes -----------------------------------------------------------
#include <map>
#include <new>
#include <stdio.h>
#include <string>
@@ -52,6 +53,8 @@
enum { B_FLATTENABLE_TYPE = 'FLAT' };
using namespace std;
namespace BPrivate {
class BMessageBody
+3
View File
@@ -29,6 +29,7 @@
#define MESSAGEFIELD_H
// Standard Includes -----------------------------------------------------------
#include <new>
#include <cstdio>
#include <cstdlib>
#include <vector>
@@ -58,6 +59,8 @@
#define MSG_LAST_ENTRY 0x0
using namespace std;
// Globals ---------------------------------------------------------------------
namespace BPrivate {
+7 -7
View File
@@ -73,36 +73,36 @@
#error you need to define DEBUG_MSG_PREFIX with the module name
#endif
#define FUNC_NAME DEBUG_MSG_PREFIX __FUNCTION__ ": "
#define FUNC_NAME DEBUG_MSG_PREFIX, __FUNCTION__
#define SHOW_FLOW(seriousness, format, param...) \
do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
dprintf( "%s"##format"\n", FUNC_NAME, param ); DEBUG_WAIT \
dprintf( "%s%s: "format"\n", FUNC_NAME, param ); DEBUG_WAIT \
}} while( 0 )
#define SHOW_FLOW0(seriousness, format) \
do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
dprintf( "%s"##format"\n", FUNC_NAME); DEBUG_WAIT \
dprintf( "%s%s: "format"\n", FUNC_NAME); DEBUG_WAIT \
}} while( 0 )
#define SHOW_INFO(seriousness, format, param...) \
do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
dprintf( "%s"##format"\n", FUNC_NAME, param ); DEBUG_WAIT \
dprintf( "%s%s: "format"\n", FUNC_NAME, param ); DEBUG_WAIT \
}} while( 0 )
#define SHOW_INFO0(seriousness, format) \
do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
dprintf( "%s"##format"\n", FUNC_NAME); DEBUG_WAIT \
dprintf( "%s%s: "format"\n", FUNC_NAME); DEBUG_WAIT \
}} while( 0 )
#define SHOW_ERROR(seriousness, format, param...) \
do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
dprintf( "%s"##format"\n", FUNC_NAME, param ); DEBUG_WAIT_ERROR \
dprintf( "%s%s: "format"\n", FUNC_NAME, param ); DEBUG_WAIT_ERROR \
}} while( 0 )
#define SHOW_ERROR0(seriousness, format) \
do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
dprintf( "%s"##format"\n", FUNC_NAME); DEBUG_WAIT_ERROR \
dprintf( "%s%s: "format"\n", FUNC_NAME); DEBUG_WAIT_ERROR \
}} while( 0 )
#endif
+1 -1
View File
@@ -784,7 +784,7 @@
#define NV_REG32(r_) ((vuint32 *)regs)[(r_) >> 2]
/* read and write to PCI config space */
#define CFGR(A) (nv_pci_access.offset=NVCFG_##A, ioctl(fd,NV_GET_PCI, &nv_pci_access,sizeof(nv_pci_access)), nv_pci_access.value)
#define CFGR(A) (*(nv_pci_access.offset=NVCFG_##A, ioctl(fd,NV_GET_PCI, &nv_pci_access,sizeof(nv_pci_access)), &nv_pci_access.value))
#define CFGW(A,B) (nv_pci_access.offset=NVCFG_##A, nv_pci_access.value = B, ioctl(fd,NV_SET_PCI,&nv_pci_access,sizeof(nv_pci_access)))
/* read and write from ISA I/O space */
@@ -10,6 +10,12 @@
#include <util/AutoLock.h>
// instantiations
#include <KDiskDevice.h>
#include <KDiskDeviceManager.h>
#include <KDiskSystem.h>
#include <KPartition.h>
namespace BPrivate {
namespace DiskDevice {
@@ -93,7 +93,7 @@ class List {
}
private:
friend class IteratorType;
friend class DoublyLinked::Iterator<Item, LinkMember>;
Link fLink;
};
+3 -1
View File
@@ -11,6 +11,8 @@
#include <OS.h>
#include <TypeConstants.h>
class BMessage;
namespace BPrivate {
class KMessageField;
@@ -100,7 +102,7 @@ public:
private:
friend class KMessageField;
friend class BMessage; // not so nice, but makes things easier
friend class ::BMessage; // not so nice, but makes things easier
struct Header {
uint32 magic;
+5 -2
View File
@@ -127,8 +127,11 @@ private:
int32 _FindInsertionIndex(const Key &key, bool &exists) const;
private:
friend class Entry;
friend class ConstEntry;
// friend class Entry;
// friend class ConstEntry;
friend class VectorMapEntry<KeyReference, Value, _Entry, Class>;
friend class VectorMapEntry<KeyReference, const Value, const _Entry,
const Class>;
ElementVector fElements;
EntryStrategy fEntryStrategy;
+2
View File
@@ -6,6 +6,8 @@
#ifndef _DATA_EXCHANGE_H
#define _DATA_EXCHANGE_H
#include <string.h>
#include <MediaFormats.h>
#include <MediaNode.h>
#include <MediaAddOn.h>
+1 -1
View File
@@ -12,7 +12,7 @@
struct sockaddr;
#define NET_STACK_DRIVER_DEV "net/stack"
#define NET_STACK_DRIVER_PATH "/dev/" ## NET_STACK_DRIVER_DEV
#define NET_STACK_DRIVER_PATH "/dev/" NET_STACK_DRIVER_DEV
enum {
// Paranoia mode: be far away of B_DEVICE_OP_CODES_END opcodes!!!
+2
View File
@@ -7,6 +7,8 @@
* It's used by Pulse, AboutHaiku, and sysinfo.
*/
#include <stdlib.h>
#include <OS.h>
#ifdef __cplusplus