Post Go back to editing

使用ADSP21489, 关于CCES中编程的数据sizeof(char)问题

Thread Summary

The user encountered unexpected sizes for char, short, int, and long types in a SHARC 21489 program, all returning 1. The final answer explains that the 21489 only supports word addressing, not byte addressing, resulting in char, short, int, and long being 32 bits, and long long being 64 bits. The issue is due to the compiler's handling of word addressing, where it loads data in 32-bit chunks.
AI Generated Content

#include <sys/platform.h>
#include "adi_initialize.h"
#include "demo.h"

/**
* If you want to use command program arguments, then place them in the following string.
*/
char __argv_string[] = "";

int main(int argc, char *argv[])
{
/**
* Initialize managed drivers and/or services that have been added to
* the project.
* @return zero on success
*/
adi_initComponents();

/* Begin adding your custom code here */
int len1 = sizeof(char);
int len2 = sizeof(short);
int len3 = sizeof(int);
int len4 = sizeof(long);
int len5 = sizeof(long long);


return 0;
}
调试显示len1/2/3/4的值都是1,len5的值是2。不是期望的值1,2, 4, 4, 8。请问是怎么回事?