issue reading c++ line

Hi,
I'm trying to read a line but I don't get what it's supposed to do.

x86emitter.cpp
1
2
3
4
5
6
7
template void xWrite<u8>( u8 val );

// __fi is force inline
__fi void xWrite8( u8 val )
{
	xWrite( val );
}


x86types.h
1
2
// __tls_emit is __threadlocal
extern __tls_emit u8*			x86Ptr;


internal.h
1
2
3
4
5
6
	template< typename T > inline
		void xWrite( T val )
	{
		*(T*)x86Ptr = val; //this one confuses me
		x86Ptr += sizeof(T);
	}
Last edited on
I'm trying out bugfixing of existing c++ programs on git.
I have a memory access violation on that line when building the program

It should convert character encoding (utf-8)
I get studio 2015 "can't read memory" on x86Ptr.
in debugging val has a value

Thanks, :)

If you read line 4 of the OP from right to left, skipping the parentheses, it would be something like:
x86Ptr is a variable;
x86Ptr is pointer variable;
x86Ptr is pointer variable to type T;
x86Ptr is pointer variable to type T that has been dereferenced;

To use it however x86Ptr need to be declared first, so:
1
2
3
4
5
6
7
template< typename T > inline
void xWrite( T val )
{
        T* x86Ptr{};
	*(x86Ptr) = val;
	x86Ptr += sizeof(T);
}

However what does the last statement in the function - address of x86Ptr += sizeof(T)???

Last edited on
x86Ptr = x86Ptr + sizeof(T);
:)
I can read it,
but I don't know yet why he does that :p
Last edited on
Yes, I wasn't asking for an explanation with += means but rather why?
Topic archived. No new replies allowed.