A
A
Alexander2018-08-13 14:56:26
Python
Alexander, 2018-08-13 14:56:26

How to call a function in C++?

Python Cython C++
Compiling a library to play wav
cpp

#include <windows.h> //библиотека audiere её требует
#include <conio.h>
#include <audiere.h> //сама библиотека

#pragma comment(lib, "audiere.lib")

using namespace audiere;

class COpenSound // имя класса

{
    public: // спецификатор доступа
        AudioDevicePtr device = OpenDevice();
        OutputStreamPtr sound = OpenSound(device , "test.wav" , false);
        sound::play();

}; // конец объявления класса COpenSound

pyx
# distutils: language = c++

cdef extern from "SoundPlay.cpp":
    cdef cppclass COpenSound:
        COpenSound() except +

cdef class OpenSound:
    cdef COpenSound *thisptr

    def __cinit__(self):
        self.thisptr = new COpenSound()

    def __dealloc__(self):
        del self.thisptr

Build error
C:\PyScripterProjects\РасширенияДляPython3НаC++\Sound play>py setup.py build_ext
 --inplace
running build_ext
building 'sound_play' extension
C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /
GL /DNDEBUG /MD -IC:\Python36\include -IC:\Python36\include "-IC:\Program Files\
Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files\Windows Kits\10\inc
lude\10.0.10240.0\ucrt" "-IC:\Program Files\Windows Kits\8.1\include\shared" "-I
C:\Program Files\Windows Kits\8.1\include\um" "-IC:\Program Files\Windows Kits\8
.1\include\winrt" /EHsc /Tpsound_play.cpp /Fobuild\temp.win32-3.6\Release\sound_
play.obj
sound_play.cpp
c:\pyscripterprojects\расширениядляpython3наc++\sound play\SoundPlay.cpp(16): er
ror C2653: 'sound': is not a class or namespace name
c:\pyscripterprojects\расширениядляpython3наc++\sound play\SoundPlay.cpp(16): er
ror C4430: missing type specifier - int assumed. Note: C++ does not support defa
ult-int
c:\pyscripterprojects\расширениядляpython3наc++\sound play\SoundPlay.cpp(16): wa
rning C4183: 'play': missing return type; assumed to be a member function return
ing 'int'
error: command 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe
' failed with exit status 2

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question