---
name: "SDL_copyp"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_copyp"
---

# SDL\_copyp(3)

A macro to copy memory between objects, with basic type checking.

## NAME

SDL\_copyp - A macro to copy memory between objects, with basic type checking.

## HEADER FILE

Defined in SDL3/SDL\_stdinc.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**#define SDL\_copyp(dst, src)                                                                 .BI** *{***SDL\_COMPILE\_TIME\_ASSERT(SDL\_copyp,***sizeof***(\*(dst))***==***sizeof***(\*(src)));***}***.BI*    **SDL\_memcpy((dst), (src), sizeof(\*(src)))**

## DESCRIPTION

**SDL\_memcpy**\
  and  **SDL\_memmove**\
  do not care where you copy memory to and from, which can lead to bugs. This macro aims to avoid most of those bugs by making sure that the source and destination are both pointers to objects that are the same size. It does not check that the objects are the same \_type\_, just that the copy will not overflow either object.

The size check happens at compile time, and the compiler will throw an error if the objects are different sizes.

Generally this is intended to copy a single object, not an array.

This macro looks like it double-evaluates its parameters, but the extras them are in **sizeof** sections, which generate no code nor side-effects.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.
