Well I was thinking about this and was wondering what the standard means of creating a new base type in C was?
For instance if I wanted to implement a string type in much the same way as a C++ string type I could type def string to a char*, but obviously I would want to automatically allocate memory to the string passed to the string variable if it was set or do so at a later time so that either of the following bits of code would work:
Obviously string would need to point to a function that handles all the memory allocation, resizing and destroying if the variable drops out of scope.
Does anyone have any experience with this?
For instance if I wanted to implement a string type in much the same way as a C++ string type I could type def string to a char*, but obviously I would want to automatically allocate memory to the string passed to the string variable if it was set or do so at a later time so that either of the following bits of code would work:
Code:
string myString = "Test";
string myStringEmpty;
Obviously string would need to point to a function that handles all the memory allocation, resizing and destroying if the variable drops out of scope.
Does anyone have any experience with this?