Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

S5pv210 SD card macro definition C code explanation

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

First, analyze C code:

((bool () (int, unsigned int, unsigned short, unsigned int, bool)) (unsigned int) 0xD0037F98) ((bool () (int, unsigned int, unsigned short, unsigned int, bool)

It seems to be a very complex macro definition, so let's analyze it now.

# define CopySDMMCtoMem (zrecoery a recorder breco cpene)

Replace (bool () (int, unsigned int, unsigned short,unsigned int, bool)) (unsigned int) 0xD0037F98) with CopySDMMCtoMem (zjorie) instead of (unsigned int)

Question: so what is the next paragraph?

A: it is divided into two paragraphs

(1) one paragraph is

(bool () (int, unsigned int, unsigned short,unsigned int, bool), this is actually defining a function type, which is a cast function.

(2) the other paragraph is (unsigned int) 0xD0037F98). This is a function. A function named "CopySDMMCtoMem" is stored in the address 0xD0037F98, and the address is dereferenced, and the function CopySDMMCtoMem is obtained.

So: the purpose of the # define here is to cast the type of the function, defining the type of the parameter and the type of the return value.

Second, analyze the c language

Typedef bool (pCopySDMMC2Mem) (int, unsigned int, unsigned short, unsigned int, bool)

If you don't understand this sentence, let me show you the usage of typedef below.

Typedef can be used in two ways:

A general form that defines aliases for existing types

Typedef type definition name

Create a new type

Typedef returns the value type new type name (parameter list)

1) typedef int NUM [10]; / / declare integer array types

NUM n / defines n as an integer array variable, where n [0]-n [9] is available

2) typedef char* STRING;// declares STRING as a character pointer type

STRING pjournal s [10]; / / p is the character pointer variable, s is the pointer array

3) typedef int (* POINTER) (); / / declares POINTER as a pointer to a function, which returns an integer value with no arguments

The pointer variable of POINTER P1pl p1pp2 is a pointer variable of type POINTER see here do you understand so it is similar to the third one; for detailed usage of typedef please see the link for advanced usage of typedef: https://www.cnblogs.com/rainbow70626/p/8647735.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report