QB64 Phoenix Edition
Question about "Sub memcpy ..." - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Question about "Sub memcpy ..." (/showthread.php?tid=2860)



Question about "Sub memcpy ..." - Kernelpanic - 07-12-2024

While reading the wiki I came across Offset(function): https://qb64phoenix.com/qb64wiki/index.php/OFFSET_(function)

The sub "memcpy" is apparently a fixed procedure, because when I changed the name there was an error during compilation.
What is this "memcpy"? Hard-wired?  I couldn't find anything about it in the wiki.

Code: (Select All)

Option _Explicit

Declare CustomType Library
  Sub zeichenKopieren (ByVal Ziel As _Offset, Byval Quelle As _Offset, Byval Bytes As Long)
End Declare

Dim As String zahlen, buchstaben

zahlen = "1234567890"
buchstaben = "ABCDEFGHIJ"

zeichenKopieren _Offset(zahlen) + 5, _Offset(buchstaben) + 5, 5
Print zahlen

End

Quote:internal\c\c_compiler\bin\c++.exe -Wl,--stack,26777216 -std=gnu++17 -fno-strict-aliasing -Wno-conversion-null -DGLEW_STATIC -DFREEGLUT_STATIC -Iinternal\c\libqb/include -Iinternal\c/parts/core/freeglut/include -Iinternal\c/parts/core/glew/include -DDEPENDENCY_NO_SOCKETS -DDEPENDENCY_NO_PRINTER -DDEPENDENCY_NO_ICON -DDEPENDENCY_NO_SCREENIMAGE internal\c/qbx.cpp -c -o internal\c/qbx.o
In file included from internal\c/qbx.cpp:1894:
internal\c/../temp/maindata.txt: In function 'void QBMAIN(void*)':
internal\c/../temp/maindata.txt:1:55: error: 'zeichenKopieren' was not declared in this scope
    1 | SUB_ZEICHENKOPIEREN=(CUSTOMCALL_SUB_ZEICHENKOPIEREN*)&zeichenKopieren;
      |                                                      ^~~~~~~~~~~~~~~
mingw32-make: *** [Makefile:402: internal\c/qbx.o] Error 1
That is OK.
Code: (Select All)

'12. Juli 2024

Option _Explicit

Declare CustomType Library
  Sub memcpy (ByVal Ziel As _Offset, Byval Quelle As _Offset, Byval Bytes As Long)
End Declare

Dim As String zahlen, buchstaben

zahlen = "1234567890"
buchstaben = "ABCDEFGHIJ"

memcpy _Offset(zahlen) + 5, _Offset(buchstaben) + 5, 5
Print zahlen

End



RE: Question about "Sub memcpy ..." - Pete - 07-12-2024

MEMCPY() is a C++ statement. My guess is you may be correct is presuming it is 'hard copied' as a C++ library function.

Pete


RE: Question about "Sub memcpy ..." - Kernelpanic - 07-12-2024

(07-12-2024, 05:36 PM)Pete Wrote: MEMCPY() is a C++ statement. My guess is you may be correct is presuming it is 'hard copied' as a C++ library function.

Pete
Ah thanks, that explains the error message.


RE: Question about "Sub memcpy ..." - Kernelpanic - 07-12-2024

Yes, memcpy() is a C function:

Code: (Select All)

//memcpy(), C-Befehlsbibliothek S. 323
//12. Juli 2023

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define GROESSE 50

int main(void)
{
char puffer1[GROESSE], puffer2[GROESSE];

strcpy(puffer1, "Das ist ein Test!");
printf("\nPuffer1: ");
printf(puffer1);

//Inhalt von P1 nach P2 kopieren
memcpy(puffer2, puffer1, GROESSE);
printf("\n\nKopiert nach Puffer2: ");
printf (puffer2);

return(0);
}



RE: Question about "Sub memcpy ..." - SMcNeill - 07-12-2024

Not to be confused with _MEMCOPY, which is one of our built-in mem commands: https://qb64phoenix.com/qb64wiki/index.php/MEMCOPY


RE: Question about "Sub memcpy ..." - Kernelpanic - 07-12-2024

(07-12-2024, 06:50 PM)SMcNeill Wrote: Not to be confused with _MEMCOPY, which is one of our built-in mem commands: https://qb64phoenix.com/qb64wiki/index.php/MEMCOPY
Yes, thanks! I looked at everything, but couldn't find it using memcpy.