summaryrefslogtreecommitdiff
path: root/tests/run/coercearraytoptr.pyx
blob: 7d146ba50c66a55cbbe8f9ebfba8271a536d00f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
cdef char* cstring = "abcdefg"

cdef void spam(char *target):
    cdef char* s = cstring
    while s[0]:
        target[0] = s[0]
        s += 1
        target += 1
    target[0] = c'\0'

cdef struct Grail:
    char silly[42]

def eggs():
    """
    >>> print(str(eggs()).replace("b'", "'"))
    ('abcdefg', 'abcdefg')
    """
    cdef char[42] silly
    cdef Grail grail
    spam(silly)
    spam(grail.silly)
    return silly, grail.silly