This isn’t working in visual studio 2010 , it gives me the following error
void main (void)
{
unsigned char* test = "ATGST";
}
Edit 1: My question is why this works on Embedded systems, but doesn’t work on PC?
But when I change it to :
char* test = "ATGST";
it works.
The main thing that I write code for embedded systems using C, and I use visual studio to test some functions so I don’t have to test it in real time on a Micro-controller.
I need an explanation, because Micro-controllers accepts the first code.

Edited to conform to the removal of the C++ tag and to appease the embedded tag.
First, the problem at hand, you are trying to pass a
char[]literal into anunsigned char*. You can’t really equate char with eitherunsignedorsigned, it is a bit special in that regard. Also, a string literal is given unique storage and should never be modified. If you’re dealing with characters, you need to use a standardchar*in whichchar[]can decay into. You could forcefully cast it, but I don’t like to recommend such things. It is safe to do, as one of the comments pointed out. Actually, it is actually one of the rare things that are really a safety no-brainer.But there is far too little space for a tight answer to provide enough qualification on reinterpret_casting, which is basically saying to the compiler that you know what you’re doing. That is potentially very dangerous and should only be done when you’re quite sure about the problem at hand. The char is usually just generic, not even signed or unsigned. Since an unsigned char has a bigger range than a char and usually char uses the positive subset of the signed char to describe characters (or any other kind of data that can fit), if your data is not in the extended positive range, you’re good to go. But, do conform to the environment and code safely.
On the entry point function – conforming edit
Since it has been established that you work on an embedded system, this implies that your program is very likely not required to return anything, so it can remain
void main()(it could also be the case that it requires very different returns specified by the given embedded system, the OP knows the most about the requirements his system imposes). In a lot of cases, the reason you can remain with void is because there is no environment/OS to appease, nobody to communicate with. But embedded systems can also be quite specialized and it is best to approach by studying the given platform in detail in order to satisfy the requirements imposed (if any).