Forum > Beginners

Some Code in C language cannot be translated to Pascal

(1/2) > >>

TYDQ:

--- Code: C  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---typedefEFI_STATUS(EFIAPI *EFI_ALLOCATE_PAGES) (    IN EFI_ALLOCATE_TYPE            Type,    IN EFI_MEMORY_TYPE              MemoryType,    IN UINTN                        NoPages,    OUT EFI_PHYSICAL_ADDRESS        *Memory    ); typedefEFI_STATUS(EFIAPI *EFI_FREE_PAGES) (    IN EFI_PHYSICAL_ADDRESS         Memory,    IN UINTN                        NoPages    ); typedefEFI_STATUS(EFIAPI *EFI_GET_MEMORY_MAP) (    IN OUT UINTN                    *MemoryMapSize,    IN OUT EFI_MEMORY_DESCRIPTOR    *MemoryMap,    OUT UINTN                       *MapKey,    OUT UINTN                       *DescriptorSize,    OUT UINT32                      *DescriptorVersion    );This codes shows a error when I use h2pas in fpc,awfully I cannot translate it by myself.Have anyone can translate this C code to the Pascal(h2pas cannot to be used in translate this C code fragment because of errors)?

Nitorami:
Try this

https://www.codeconvert.ai/free-converter

Works very well

marcov:
C headers are not 100% automated translatable, specially when they use macros (like IN and OUT here)

Remy Lebeau:

--- Quote from: TYDQ on April 04, 2024, 04:37:57 pm ---Have anyone can translate this C code to the Pascal(h2pas cannot to be used in translate this C code fragment because of errors)?

--- End quote ---

Try something like this:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  EFI_ALLOCATE_PAGES = function(    Type: EFI_ALLOCATE_TYPE;    MemoryType: EFI_MEMORY_TYPE;    NoPages: UINTN;    out Memory: EFI_PHYSICAL_ADDRESS  ): EFI_STATUS; cdecl;   EFI_FREE_PAGES = function(    Memory: EFI_PHYSICAL_ADDRESS;    NoPages: UINTN  ): EFI_STATUS; cdecl;   EFI_GET_MEMORY_MAP = function(    var MemoryMapSize: UINTN;    var MemoryMap: EFI_MEMORY_DESCRIPTOR;    out MapKey: UINTN;    out DescriptorSize: UINTN;    out DescriptorVersion: UINT32  ): EFI_STATUS; cdecl;

WooBean:
As "Type" is not the best choice for a parameter name I'd propose a small addition:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- EFI_ALLOCATE_PAGES = function(    &Type: EFI_ALLOCATE_TYPE; //or "aType"    MemoryType: EFI_MEMORY_TYPE;    NoPages: UINTN;    out Memory: EFI_PHYSICAL_ADDRESS  ): EFI_STATUS; cdecl; 

Navigation

[0] Message Index

[#] Next page

Go to full version