This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 »
646
Announcements / Re: stdio.h
« on: November 20, 2009, 05:51:32 pm »Try using pointers instead of arrays. It works for me.Yes, dynamic arrays work. Static arrays do not work unless you actually define the size of the array, which usually isn't what you want.
int x[] = int* x
647
Announcements / Re: stdio.h
« on: November 19, 2009, 07:46:32 pm »Apparently, the GCC. It yelled at me when I tried.Also, something I found out:Who says they can't?Code: [Select]int (*blah)(int,int)[];
Is a pointer to a function which returns an array (and, functions cannot).
649
Announcements / Re: stdio.h
« on: November 16, 2009, 03:15:24 pm »
You could use execute_asm(). :/
Also, another question - why is execute_shell() not implemented when it really is just a call for system()? or is it?
Also, another question - why is execute_shell() not implemented when it really is just a call for system()? or is it?
650
Announcements / Re: stdio.h
« on: November 15, 2009, 09:38:08 pm »
Stupid question: is referring to an array going to be able to refer to the first element purely for GM compatibility? Personally, I'd never enable this, ever, but it would be useful for those directly converting from GM. Also, is LGM/unfinished IDE going to use a format better than GMK/GM6? Please?
651
Issues Help Desk / Re: Pointer explosion
« on: November 15, 2009, 09:34:56 pm »uint8 requirement(int64 value){return value&0xFFFFFF00?(value&0xFFFF0000?(value&0xFF000000?8:4):2):1;}Yeah, I happened to realize that about a week ago, and then I just figured "screw this" and started working on something else.
uint8 requirement(int8 value) { return requirement((int64)value); }
Why not just return 1?
Anyways the idea is pretty lame since you have to deal with the memory overhead of a void* and all and you waste memory dealing with all that so yeah, pretty silly
652
Off-Topic / Re: Who knows where to download I AM A GIGANTIC FAGGOT PLEASE BAN ME 5.0 Palladium?
« on: November 13, 2009, 05:02:17 pm »Though, apparently some spammers are paying people to manually register and spam.Laughing.
653
General ENIGMA / Re: Hardware Acceleration
« on: November 10, 2009, 04:15:51 pm »Sorry, is that directed at me or a continuation of what I said?Oh, wow, I didn't realize this. It's a continuation of what you said. :/
654
General ENIGMA / Re: Hardware Acceleration
« on: November 09, 2009, 08:44:34 pm »If you're basing this on an Nvidia subset on the basis that that's 'standard' (like Wine does) thenyou are an idiot and deserve to be stepped on
655
Issues Help Desk / Re: General Question
« on: November 06, 2009, 10:16:21 pm »
You download both the core and r3. r3 should include LGM with the ability to use ENIGMA.
However, both are essentially pre-alpha, so it's virtually useless outside testing.
However, both are essentially pre-alpha, so it's virtually useless outside testing.
656
Issues Help Desk / Re: Pointer explosion
« on: November 06, 2009, 03:49:47 pm »Just for the record, you put there some unnecessary break statements on get(). Once you use "return", the code is immediatly interrupted.Sorry; just happens to be a habit. I'll do that.
Quote
Why are you casting to int64 in some cases and int32 in the case 4?Typo/mistake thing.
Quote
Also, you are using "delete" to a void* variable. Perhaps free() would be better?
Quote
In third place, your definition of resize has no effect(apart from leaking memory, of course, and increase the risk of future segmentation faults). So I assume you didn't actually notice how you implemented it.I can't believe I forgot about malloc and free. That'll do it.
Quote
In fourth place, check stdint.h. You might just love it(it defines int8_t, etc.)Would care, but I prefer it without the _t. I could use that for my typedefs, however.
Quote
Also, you are missing the ';' after the class.Another thing I forgot to do. >_>
Quote
Last but not least, you really shouldn't name float "decimals". Because they are not. decimals are a data type that uses the decimal system, rather than binary. It is useful to avoid some rounding errors. Float, double and long double are not decimals.I was going to name them rationals, and I'll probably do that.
Anyways, thanks a bunch.
EDIT: Hooray, it works.
And, now, to seem stupid, how do I make two different operators for ++x and x++? Also, I was hoping this would work, but I guess not:
Code: [Select]
// Add functions to use varint in I/O streams
std::ostream::operator <<(varint &x)
{
int64 y=(int64)x;
this << y;
return this;
}
std::istream::operator >>(varint &x)
{
int64 y;
this >> y;
x=y;
return this;
}
Full code:
http://pastebin.com/f55576a04
657
Issues Help Desk / Pointer explosion
« on: November 05, 2009, 07:05:17 pm »Code: [Select]
// Only include once
#ifndef TYPES_INCLUDED
#define TYPES_INCLUDED 1
// Include C headers
#include <climits>
#include <cfloat>
// Define 1-bit integer
typedef bool int1;
// Define 8-bit integer
typedef signed char int8;
typedef unsigned char uint8;
// Define 16-bit integer
typedef signed short int int16;
typedef unsigned short int uint16;
// Define 32-bit integer
typedef signed int int32;
typedef unsigned int uint32;
// Define 64-bit integer
typedef signed long long int int64;
typedef unsigned long long int uint64;
// Size function - returns lowest size in bytes required to set value
uint8 requirement(int64 value)
{
if (value>=CHAR_MIN || value<=CHAR_MAX)
{
return 1;
}
else if (value>=SHRT_MIN || value<=SHRT_MAX)
{
return 2;
}
else if (value>=INT_MIN || value<=INT_MAX)
{
return 4;
}
else
{
return 8;
}
}
// Define variable-sized integer
class varint
{
// Make pointer to value
public: void *value;
private: uint8 size;
// Make constructor
public: varint() { resize(1);set(0); }
public: varint(int64 x) { resize(requirement(x));set(x); };
public: varint(int64 x,uint8 size) { resize(size);set(x); };
// Set function - sets value to *value
private: void set(int64 x)
{
switch (size)
{
case 1:
int8 *value8;value8=(int8*)value;*value8=x;
break;
case 2:
int16 *value16;value16=(int16*)value;*value16=x;
break;
case 4:
int32 *value32;value32=(int32*)value;*value32=x;
break;
case 8:
int64 *value64;value64=(int64*)value;*value64=x;
break;
}
}
// Get function - gets value of *value
private: int64 get()
{
switch (size)
{
case 1:
int8 *value8=(int8*)value;
return (int64)*value8;
break;
case 2:
int16 *value16=(int16*)value;
return (int64)*value16;
break;
case 4:
int32 *value32=(int32*)value;
return (int32)*value32;
break;
case 8:
int64 *value64=(int64*)value;
return (int64)*value64;
break;
}
}
// Resize function
public: void resize(uint8 bytes)
{
// Invalid number of bytes?
if (bytes!=1 && bytes!=2 && bytes!=4 && bytes!=8)
{
return;
}
// Resize if lower size is given only if lower == true
if (sizeof(value)!=bytes)
{
void *temp=value;
delete value;
switch (bytes)
{
case 1:
void *value=new int8;value=temp;
break;
case 2:
void *value=new int16;value=temp;
break;
case 4:
void *value=new int32;value=temp;
break;
case 8:
void *value=new int64;value=temp;
break;
}
}
// Set size variable
size=bytes;
}
// Get size function
public: size_t getsize()
{
return (size_t)size;
}
// Return operators
&operator int64() { return get(); }
&operator int32() { return get(); }
&operator int16() { return get(); }
&operator int8() { return get(); }
// Define operators
int64 &operator =(int64 x) { if (requirement(x)>sizeof(value)) { resize(sizeof(x)); } set(x);return get(); }
int32 &operator =(int32 x) { if (requirement(x)>sizeof(value)) { resize(sizeof(x)); } set(x);return get(); }
int16 &operator =(int16 x) { if (requirement(x)>sizeof(value)) { resize(sizeof(x)); } set(x);return get(); }
int8 &operator =(int8 x) { if (requirement(x)>sizeof(value)) { resize(sizeof(x)); } set(x);return get(); }
}
// Define decimals
typedef float dec32;
typedef double dec64;
typedef long double dec96;
// Define special
typedef std::string str;
// End include
#endif
Now, you know what I do when I'm bored.
Just in case you didn't pick up what this is, it's a header for various type definitions and aliases. The one I'm having trouble with is varint.
varint is a variable-sized integer. Essentially, it'll only be as big as it needs to be. If I want to make a variable with a value of 0, why do I need more than 1 byte? If it's 256, however, I'll need it to be 2 bytes. Of course, you're probably thinking: "why the hell do I care; it's only a few bytes". Well, err, I don't know what to say. But, whenever I try to compile this, g++ borks and returns tons of warnings. Anyone have any idea what I need to do to fix this? And, just for the record, it's not done; I still have the other operators to do.
658
Announcements / Re: Progress
« on: October 29, 2009, 03:20:03 pm »What the crap? Why isn't code supposed to be big? Ever seen the Linux kernel you all love so much?I think you forgot that you were talking to Josh and not me.
pages hate me
659
Announcements / Re: Progress
« on: October 27, 2009, 03:40:57 pm »DLLs are a practical way to split your executable into multiple files.The point of which is...?
660
Announcements / Re: Progress
« on: October 27, 2009, 02:22:53 pm »
Just entirely curious, what is the point of DLLs? I mean, it's useful in Linux/UNIX to have libraries so that you don't have to have twenty copies because twenty programs that use it, but why would you care in Windows, since they're always included, anyways?