提示コードの"///ここのコードです"部ですがなぜアクセスエラーが発生するのでしょうか?その関数を使っている部分を調べましたがないも問題はないと思うのですが原因がどうしてもわかりません。
cpp
1#include <iostream> 2#include "stdio.h" 3 4#include <al.h> 5#include <alc.h> 6 7#define alCall(function, ...) alCallImpl(__FILE__, __LINE__, function, __VA_ARGS__)z 8bool check_al_errors(const std::string& filename, const std::uint_fast32_t line) 9{ 10 ALenum error = alGetError(); 11 if (error != AL_NO_ERROR) 12 { 13 std::cerr << "***ERROR*** (" << filename << ": " << line << ")\n"; 14 switch (error) 15 { 16 case AL_INVALID_NAME: 17 std::cerr << "AL_INVALID_NAME: a bad name (ID) was passed to an OpenAL function"; 18 break; 19 case AL_INVALID_ENUM: 20 std::cerr << "AL_INVALID_ENUM: an invalid enum value was passed to an OpenAL function"; 21 break; 22 case AL_INVALID_VALUE: 23 std::cerr << "AL_INVALID_VALUE: an invalid value was passed to an OpenAL function"; 24 break; 25 case AL_INVALID_OPERATION: 26 std::cerr << "AL_INVALID_OPERATION: the requested operation is not valid"; 27 break; 28 case AL_OUT_OF_MEMORY: 29 std::cerr << "AL_OUT_OF_MEMORY: the requested operation resulted in OpenAL running out of memory"; 30 break; 31 default: 32 std::cerr << "UNKNOWN AL ERROR: " << error; 33 } 34 std::cerr << std::endl; 35 return false; 36 } 37 return true; 38} 39 40 41template<typename alFunction, typename... Params> 42auto alCallImpl(const char* filename, 43 const std::uint_fast32_t line, 44 alFunction function, 45 Params... params) 46 ->typename std::enable_if_t<!std::is_same_v<void, decltype(function(params...))>, decltype(function(params...))> 47{ 48 auto ret = function(std::forward<Params>(params)...); 49 check_al_errors(filename, line); 50 return ret; 51} 52 53template<typename alFunction, typename... Params> 54auto alCallImpl(const char* filename, 55 const std::uint_fast32_t line, 56 alFunction function, 57 Params... params) 58 ->typename std::enable_if_t<std::is_same_v<void, decltype(function(params...))>, bool> 59{ 60 function(std::forward<Params>(params)...); 61 return check_al_errors(filename, line); 62} 63 64#define alcCall(function, device, ...) alcCallImpl(__FILE__, __LINE__, function, device, __VA_ARGS__) 65 66bool check_alc_errors(const std::string& filename, const std::uint_fast32_t line, ALCdevice* device) 67{ 68 ALCenum error = (ALCenum)alcGetError(device);/////ここのコードです。 69 if (error != ALC_NO_ERROR) 70 { 71 std::cerr << "***ERROR*** (" << filename << ": " << line << ")\n"; 72 switch (error) 73 { 74 case ALC_INVALID_VALUE: 75 std::cerr << "ALC_INVALID_VALUE: an invalid value was passed to an OpenAL function"; 76 break; 77 case ALC_INVALID_DEVICE: 78 std::cerr << "ALC_INVALID_DEVICE: a bad device was passed to an OpenAL function"; 79 break; 80 case ALC_INVALID_CONTEXT: 81 std::cerr << "ALC_INVALID_CONTEXT: a bad context was passed to an OpenAL function"; 82 break; 83 case ALC_INVALID_ENUM: 84 std::cerr << "ALC_INVALID_ENUM: an unknown enum value was passed to an OpenAL function"; 85 break; 86 case ALC_OUT_OF_MEMORY: 87 std::cerr << "ALC_OUT_OF_MEMORY: an unknown enum value was passed to an OpenAL function"; 88 break; 89 default: 90 std::cerr << "UNKNOWN ALC ERROR: " << error; 91 } 92 std::cerr << std::endl; 93 return false; 94 } 95 return true; 96} 97//////////////////////////////////////////////////////////////////////// 98template<typename alcFunction, typename... Params> 99auto alcCallImpl(const char* filename, 100 const std::uint_fast32_t line, 101 alcFunction function, 102 ALCdevice* device, 103 Params... params) 104 ->typename std::enable_if_t<std::is_same_v<void, decltype(function(params...))>, bool> 105{ 106 function(std::forward<Params>(params)...); 107 bool b = check_alc_errors(filename, line, device); 108 printf("ああああ"); 109 return b; 110} 111 112template<typename alcFunction, typename ReturnType, typename... Params> 113auto alcCallImpl(const char* filename,const std::uint_fast32_t line,alcFunction function,ReturnType& returnValue,ALCdevice* device,Params... params) 114 ->typename std::enable_if_t<!std::is_same_v<void, decltype(function(params...))>, bool> 115{ 116 returnValue = function(std::forward<Params>(params)...); 117 bool b = check_alc_errors(filename, line, device); 118 printf("いいいいい\n"); 119 return b; 120} 121 122///////////////////////////////////////////////////////////////////////// 123
あなたの回答
tips
プレビュー