RPC编程的时候出现的左值问题

i found a releative manual page about l-value on msdn.

you can check it here: https://msdn.microsoft.com/en-us/library/bkbs2cds.aspx

there is an example in this page, but it dose not work as it shows.

msdn上的左值演示,微软的扩展支持,当强制转换一个左值但不会改变变量的长度的时候,转换完依旧是一个左值,msdn上的示例也是想表达这个,但是实际测试的时候并没有其说明的效果,两个赋值表达式都是编译错误。

char *p ;  
short  i;  
long l;  

(long *) p = &l ;       /* Legal cast   */     // this statement can not complie sucess
(long) i = l ;          /* Illegal cast */  

i am not sure what's your result.

here is an example of mime:
然后自己写了一个实例,将char*类型指针转换成int*指针的时候,指针就无法自加了

char* pBuffer = new char[1024];

((int*)pBuffer)++;     //  the result is the same as the previous. it will issue : ++ need l-value

and the /ZA is not including in the complie cmd line.

the main purpose is that, the midl.exe will generate the samiliar code as previous. such as:

类似的midl编译一个idl文件生成的对应c文件中也有类似代码,并不能直接编译通过。不知道是不是哪里没有设置好。

[ RPCSync_s.c ]

    Result = 0;
    RpcTryFinally
        {
        RpcTryExcept
            {
            if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
                NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] );

            Param1 = *(( int __RPC_FAR * )_StubMsg.Buffer)++;   //  issue error: ++ need l-value
            Param2 = *(( int __RPC_FAR * )_StubMsg.Buffer)++;   //  issue error: ++ need l-value

i am waiting for code god to help me here, thk very much!

另外有没有C/C++实现的 RPC 同步调用的示例,能否编译通过

查了一下,这个应该是msdn写错了吧,一般来说,这样做是正常的:
char *p;
short i;
long l;

p = (char*)&l;       /* Legal cast   */
i = (short)l;          /* Illegal cast */

一般的类型转换,都是在等号右侧来做的,在左侧做,应该是无法通过吧,因为左值要求不能是一个算式,你最后这段代码,我感觉调整一下括号似乎可以,因为主要问题是内部那个自加变量进行了类型转换造成的,比如以下代码:
long l;
char* pBuffer = new char[1024];
strcpy(pBuffer, "11112222");
l = *(long *)(pBuffer);
l = *(long *)((pBuffer) += sizeof(long));
后面两次执行的结果,long分别是0x31313131,0x32323232,这样一个做法应该是可以达到目的的,请看一下,调整一下括号