This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Weird behaviour with struct

#include "compiler_defs.h"
#include "C8051f380_defs.h"
#include <stddef.h>




struct MASTER
{

	int cmd[2];
};

xdata struct MASTER mstr;




//-----------------------------------------------------------------------------
void main(void)
{

	while(1)
	{
		char a;
		
		if(mstr.cmd==0)a=0;

		if(mstr.cmd[1]==0)a=0;
	}

}

Hi guys:

The attached code has a structure with one member array of 2 elements. This code compiles and it shouldn't: note in main() that there's access to the member without an index and the compiler is not giving any error.

What's going on here?

I am using Silabs 8051F380 processorC51 , compiler V9.55, and BL linker V6.22

Thanks!!!