during my adventures in C++ i also wanted to create a new data independent from the types defined in c++;not as an objective, but out of mere curiosity...
If you really want to do that i would recommend using the __asm__ keyword
within assembly data is not predefined into types; all data is just sequences of bytes stored in the data segment of a program. basic syntax for creating such a thing would be
__asm__ resb 64 myCrazyData;
__asm__ resb 64 myCrazyData;
or alternately
__asm__
{
resb 64 sixty_four_byte_var
};
I'm not sure about the exact syntax but these will give you the basic idea.
Also, you will most likely have to use assembler math commands(inc,add,sub,mul,div,etc.) i would recommend reading a text on the different assembler math commands as there are a wide variety. Also, when in assembler variable scope does not apply and you can multiply and divide and variable you have declared in c in your assembler except those that have already been garbage collected. here is an example:
int main()
{
int main_asm_var=2;
asm_func();
}
int asm_func()
{
int local_asm_var=1;
__asm__
{
resb 4 four_byte_var
mov eax four_byte _var
add local_asm_var eax
add main_asm_var eax
};
}
*note* some of the assembler syntax may be incorrect as i have not worked in assembler for some years
*another note*after you create data chunks larger than 4bytes math can get very complicated because of CPU register size- i would suggest reading up on it before you try it.
both add methods work because there is no variable scope. Also, this is just one way i have seen 1 (windows) compiler use the asm keyword- the GNU C Compiler(GCC), for example, takes each command as a string in a function-like interface
asm("command 1","command 2",etc.);
as for smallest data types accessible-usually people stick with the byte or char data types-for the unicode seet of chars you can use wide_t(2 bytes) and if you really want to manage individual bits, theres always bit fields. Bit fields are declared in structs(a collection of data) or unions(more than one type of data which shares the same memory location) in this form
struct tcp
{
unsigned short int th_sport;
unsigned short int th_dport;
unsigned int th_seq;
unsigned int th_ack;
unsigned char th_x2:4, th_off:4;
//here is the union which combines the 1byte of flags(char) with the
//6 1-bit bitfields that represent the tcp flags
union FLAGS
{
unsigned char th_flags;
unsigned char urg:1,ack:1,psh:1,rst:1,syn:1,fin:1;
}flags;
unsigned short int th_win;
unsigned short int th_sum;
unsigned short int th_urp;
};
here i am using an actual example from one of my programs to show the use of bitfields-each bit-field represents a 1-byte flag used to indicate something in a TCP packet header-here is a bitfield on its own:
char myBitField:1
However, before you go ahead and start bit-fielding willy-nilly, I would recommend reading more on them as they have some serious safety drawbacks due to the inability of most machines to manipulate individual bits and differing machine bit-order;
P.S. I should probably also note that technically this is not c++ and I wholly agree with the above posters that you should try to build on the foundations already laid in c++...they are absolutely correct in that you should use what already exists(classes, arrays, etc.) as opposed to trying to actually create a data type with assembler. What I am showing you is not really c++ it is using assembler through a window in c++