本文整理汇总了C++中printErr函数的典型用法代码示例。如果您正苦于以下问题:C++ printErr函数的具体用法?C++ printErr怎么用?C++ printErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printErr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialGetC
int serialGetC(HANDLE fd, uint8_t* c, int timeout)
{
COMMTIMEOUTS timeouts;
unsigned long res;
COMSTAT comStat;
DWORD errors;
if(!ClearCommError(fd, &errors, &comStat)) {
printErr("could not reset comm errors", GetLastError());
return -1;
}
if(!GetCommTimeouts(fd, &timeouts)) {
printErr("error getting comm timeouts", GetLastError());
return -1;
}
timeouts.ReadIntervalTimeout = timeout;
timeouts.ReadTotalTimeoutConstant = timeout;
timeouts.ReadTotalTimeoutMultiplier = 10;
if(!SetCommTimeouts(fd, &timeouts)) {
printErr("error setting comm timeouts", GetLastError());
return -1;
}
if(!ReadFile(fd, c, 1, &res, NULL)) {
printErr("error reading from serial port", GetLastError());
return -1;
}
if(res != 1)
return -1;
return *c;
}
示例2: printErr
Boolean WISInput::initALSA(UsageEnvironment& env) {
do {
int arg;
#ifdef WORDS_BIGENDIAN
arg = AFMT_S16_BE;
#else
arg = AFMT_S16_LE;
#endif
if (ioctl(fOurAudioFileNo, SNDCTL_DSP_SETFMT, &arg) < 0) {
printErr(env, "SNDCTL_DSP_SETFMT");
break;
}
arg = audioSamplingFrequency;
if (ioctl(fOurAudioFileNo, SNDCTL_DSP_SPEED, &arg) < 0) {
printErr(env, "SNDCTL_DSP_SPEED");
break;
}
arg = audioNumChannels > 1 ? 1 : 0;
if (ioctl(fOurAudioFileNo, SNDCTL_DSP_STEREO, &arg) < 0) {
printErr(env, "SNDCTL_DSP_STEREO");
break;
}
return True;
} while (0);
// An error occurred:
return False;
}
示例3: serialSetBaudrate
int serialSetBaudrate(HANDLE fd, int baudrate)
{
DCB dcb;
memset(&dcb, 0x00, sizeof(dcb));
dcb.DCBlength = sizeof(dcb);
if(!GetCommState(fd, &dcb)) {
printErr("error getting serial port state", GetLastError());
return -1;
}
dcb.BaudRate = baudrate;
dcb.ByteSize = 8;
dcb.StopBits = ONESTOPBIT;
dcb.Parity = NOPARITY;
dcb.fBinary = 1;
dcb.fOutxCtsFlow = 0;
dcb.fOutxDsrFlow = 0;
dcb.fOutX = 0;
dcb.fInX = 0;
dcb.fNull = 0;
dcb.fTXContinueOnXoff = 0;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fDsrSensitivity = 0;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
if(!SetCommState(fd, &dcb)) {
printErr("error setting serial port state", GetLastError());
return -1;
}
return 0;
}
示例4: processor
/** \brief Set up event processing.
*
* Sets up the module for event processing, based on the options in the configuration file.
*
* \param conf Configuration file instance.
* \return Enum indicating the setup state.
*/
uint8_t Initializer::setUpEvtProc(shared_ptr<Config> conf) {
// Create event detector instance.
shared_ptr<EvtProcessor> processor(new EvtProcessor);
// Add operator for acceleration event detection.
shared_ptr<OpAcceleration> accEvents(new OpAcceleration(14000));
if (!processor->op_append(accEvents)) {
printErr(INIT_ERR_DEV_APPEND, "event operator");
return INIT_ERR_DEV_APPEND;
}
// Add operator for gyroscope event detection.
shared_ptr<OpGyroscope> gyroEvents(new OpGyroscope(1500));
if (!processor->op_append(gyroEvents)) {
printErr(INIT_ERR_DEV_APPEND, "event operator");
return INIT_ERR_DEV_APPEND;
}
// Finally add processors to event processing module.
this->evt.evt_append(processor);
this->evt.addChild(processor);
return INIT_OK;
}
示例5: handleTrFunctionAliases
static bool handleTrFunctionAliases(const QString &arg)
{
foreach (const QString &pair, arg.split(QLatin1Char(','), QString::SkipEmptyParts)) {
const int equalSign = pair.indexOf(QLatin1Char('='));
if (equalSign < 0) {
printErr(LU::tr("tr-function mapping '%1' in -tr-function-alias is missing the '='.\n").arg(pair));
return false;
}
const bool plusEqual = equalSign > 0 && pair[equalSign-1] == QLatin1Char('+');
const int trFunctionEnd = plusEqual ? equalSign-1 : equalSign;
const QString trFunctionName = pair.left(trFunctionEnd).trimmed();
const QString alias = pair.mid(equalSign+1).trimmed();
const int trFunction = trFunctionByDefaultName(trFunctionName);
if (trFunction < 0) {
printErr(LU::tr("Unknown tr-function '%1' in -tr-function-alias option.\n"
"Available tr-functions are: %2")
.arg(trFunctionName, availableFunctions().join(QLatin1Char(','))));
return false;
}
if (alias.isEmpty()) {
printErr(LU::tr("Empty alias for tr-function '%1' in -tr-function-alias option.\n")
.arg(trFunctionName));
return false;
}
trFunctionAliasManager.modifyAlias(trFunction, alias.toLatin1(),
plusEqual ? TrFunctionAliasManager::AddAlias : TrFunctionAliasManager::SetAlias);
}
return true;
}
示例6: main
int main(int argc, char** args)
{
char s[1024+1];
gets_s(s);
void* expr;
int res = ParseExpression(s, 1024, &expr);
printErr("ParseExpression", res);
if (res <= 0)
return 1;
res = PrintExpression(expr, s, 1024);
printErr("PrintExpression", res);
if (res <= 0)
return 1;
s[res] = 0;
printf("%s\n", s);
uint8 output[1024];
res = CompileExpression(expr, output, 1024, IdentifierInfoCallback);
printErr("CompileExpression", res);
if (res <= 0)
return 1;
std::ofstream f("output.bin");
f.write((char*)output, res);
f.close();
res = ReleaseExpression(expr);
printErr("ReleaseExpression", res);
if (res <= 0)
return 1;
return 0;
}
示例7: lsc
bool LuaInterp::loadFile( const char* fileName )
{
LuaStackCheck lsc(_luaState);
int errCode = LUA_OK;
errCode = luaL_loadfile( _luaState, fileName );
if( errCode != LUA_OK )
{
printErr( "luaL_loadfile errCode %d \"%s\"\n", errCode, lua_tolstring( _luaState, -1, 0 ) );
lua_pop( _luaState, 1 );
return false;
}
int numArgs = 0;
int numResults = 0;
int ehi = 0; // error handler index
lua_getglobal( _luaState, "debug" );
lua_getfield( _luaState, -1, "traceback" );
lua_remove( _luaState, -2 );
ehi = -2;
lua_insert( _luaState, ehi );
errCode = lua_pcall( _luaState, numArgs, numResults, ehi );
if( errCode != LUA_OK )
{
printErr( "lua_pcall %d \"%s\"\n", errCode, lua_tolstring( _luaState, -1, 0 ) );
lua_pop( _luaState, 2 );
return false;
}
lua_pop( _luaState, 1 );
return true;
}
示例8: releaseTranslator
static bool releaseTranslator(Translator &tor, const QString &qmFileName,
ConversionData &cd, bool removeIdentical)
{
tor.reportDuplicates(tor.resolveDuplicates(), qmFileName, cd.isVerbose());
if (cd.isVerbose())
printOut(LR::tr("Updating '%1'...\n").arg(qmFileName));
if (removeIdentical) {
if (cd.isVerbose())
printOut(LR::tr("Removing translations equal to source text in '%1'...\n").arg(qmFileName));
tor.stripIdenticalSourceTranslations();
}
QFile file(qmFileName);
if (!file.open(QIODevice::WriteOnly)) {
printErr(LR::tr("lrelease error: cannot create '%1': %2\n")
.arg(qmFileName, file.errorString()));
return false;
}
tor.normalizeTranslations(cd);
bool ok = saveQM(tor, file, cd);
file.close();
if (!ok) {
printErr(LR::tr("lrelease error: cannot save '%1': %2")
.arg(qmFileName, cd.error()));
} else if (!cd.errors().isEmpty()) {
printOut(cd.error());
}
cd.clearErrors();
return ok;
}
示例9: initConfig
/*
* Function to initialize global config struct
*/
static Config initConfig(CMap cmap) {
char * val;
int i = 0;
Config c = mallocConfig();
FILE * file = fopen(DEFAULT_OPTIONS_FILENAME, "r");
if (file == NULL) {
die("Default config file not found.", 2);
}
defCMap = getCMap(file); /* Load default config map from file */
for (i = 0; i < ARYLEN; ++i) { /* Load default values into config ary 1st */
config[i].value = getCValue(defCMap, config[i].keyword);
}
for (i = 0; i < ARYLEN; ++i) {
val = getCValue(cmap, config[i].keyword); /* get user config value */
if (val != NULL) {
if (!setConfigValue(c, i, val)) /* check & set configuration */
printErr("Invalid parameter value: ", "initConfig()", 1); /* ... or log an error */
}
else if (!setConfigValue(c, i, config[i].value))
printErr("Error in default config file: ", "initConfig()", 1);
}
fclose(file);
return c;
}
示例10: getConeFloatArr
static int getConeFloatArr(char *key, scs_float **varr, scs_int *vsize,
PyObject *cone) {
/* get cone['key'] */
scs_int i, n = 0;
scs_float *q = SCS_NULL;
PyObject *obj = PyDict_GetItemString(cone, key);
if (obj) {
if (PyList_Check(obj)) {
n = (scs_int)PyList_Size(obj);
q = scs_calloc(n, sizeof(scs_float));
for (i = 0; i < n; ++i) {
PyObject *qi = PyList_GetItem(obj, i);
q[i] = (scs_float)PyFloat_AsDouble(qi);
}
} else if (PyInt_Check(obj) || PyLong_Check(obj) ||
PyFloat_Check(obj)) {
n = 1;
q = scs_malloc(sizeof(scs_float));
q[0] = (scs_float)PyFloat_AsDouble(obj);
} else {
return printErr(key);
}
if (PyErr_Occurred()) {
/* potentially could have been triggered before */
return printErr(key);
}
}
*vsize = n;
*varr = q;
return 0;
}
示例11: welcome
void welcome()
{
int cnt;
//open the count file.
FILE* fp = fopen((PWD + "/Config/counts.txt").c_str(),"r+");
//file error check.
if(!fp)
printErr(COUNT_FILE_ERROR);
//incrementing the count.
if(fscanf(fp, "%d", &cnt))
{
if(cnt==0)
{
giveIntro();
}
}
else
printErr(COUNT_FILE_ERROR);
}
示例12: print
static void print(const QString &fileName, int lineNo, const QString &msg)
{
if (lineNo)
printErr(QString::fromLatin1("%2(%1): %3").arg(lineNo).arg(fileName, msg));
else
printErr(msg);
}
示例13: main
int main(int argc, char *argv[])
{
int rc = 0;
if (argc == 3 || argc == 5)
{
struct stat DirStat;
if ( stat(argv[2], &DirStat) == 0
&& S_ISDIR(DirStat.st_mode))
{
char *pszContent;
rc = readFile(argv[1], &pszContent, NULL);
if (!rc)
{
FILE *pFileList = NULL;
if (argc == 5)
rc = openMakefileList(argv[3], argv[4], &pFileList);
if (argc < 4 || pFileList)
rc = splitFile(argv[2], pszContent, pFileList);
if (pFileList)
rc = closeMakefileList(pFileList, rc);
free(pszContent);
}
}
else
rc = printErr("Given argument \"%s\" is not a valid directory.\n", argv[2]);
}
else
rc = printErr("Syntax error: usage: filesplitter <infile> <outdir> [<list.kmk> <kmkvar>]\n");
return rc;
}
示例14: printErr
STATUS wdbUdpSockIfInit
(
WDB_COMM_IF * pWdbCommIf
)
{
struct sockaddr_in srvAddr;
pWdbCommIf->rcvfrom = wdbUdpSockRcvfrom;
pWdbCommIf->sendto = wdbUdpSockSendto;
pWdbCommIf->modeSet = wdbUdpSockModeSet;
pWdbCommIf->cancel = wdbUdpSockCancel;
pWdbCommIf->hookAdd = NULL;
pWdbCommIf->notifyHost = NULL;
/* Create the wdbUdpSocket */
if ((wdbUdpSock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
{
printErr ("Socket failed\n");
return (ERROR);
}
/* Bind to WDB agents port number */
bzero ((char *)&srvAddr, sizeof(srvAddr));
srvAddr.sin_family = AF_INET;
srvAddr.sin_port = htons(WDBPORT);
srvAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind (wdbUdpSock, (struct sockaddr *)&srvAddr, sizeof(srvAddr)) < 0 )
{
printErr ("Bind failed\n");
return (ERROR);
}
/* Create the wdbUdpCancelSocket */
if ((wdbUdpCancelSock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
{
printErr ("Socket failed\n");
return (ERROR);
}
/* connect it (for writes) to the wdbUdpSocket */
bzero ((char *)&srvAddr, sizeof(srvAddr));
srvAddr.sin_family = AF_INET;
srvAddr.sin_port = htons(WDBPORT);
srvAddr.sin_addr.s_addr = inet_addr ("127.0.0.1");
if (connect (wdbUdpCancelSock, (struct sockaddr *)&srvAddr, sizeof(srvAddr))
== ERROR)
{
printErr ("Connect failed\n");
return (ERROR);
}
return (OK);
}
示例15: print
static void print(const QString &fileName, int lineNo, const QString &msg)
{
if (lineNo > 0)
printErr(QString::fromLatin1("WARNING: %1:%2: %3\n").arg(fileName, QString::number(lineNo), msg));
else if (lineNo)
printErr(QString::fromLatin1("WARNING: %1: %2\n").arg(fileName, msg));
else
printErr(QString::fromLatin1("WARNING: %1\n").arg(msg));
}