4.1 snprintf

与 sprintf() 函数不同的是,snprintf() 函数提供了一个参数 size,可以防止缓冲区溢出。如果格式化后的字符串长度超过了 size-1,则 snprintf() 只会写入 size-1 个字符,并在字符串的末尾添加一个空字符(\0)以表示字符串的结束。

如果你存放 C 风格字符串,则需要一个额外的 NUL 即 '\0' 字符结束符,实际可使用的字节数会少 1 个

 strncat  会自动追加\0结束符号  遇到\0  只可以copy 到\0之前的   就算copysize<参数size 也不会强制追加

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>

void DiagR_BufferPrint(char* prefixInfo,uint8_t* pData, uint32_t dataLen)
{
#define DEBUG_DATA_PRINT_LEN (100u)
    if(dataLen < DEBUG_DATA_PRINT_LEN)
    {
        char str[6] = "";
        char buffer[500]="";
        if(0 != prefixInfo)
        {
            if(strlen(buffer) <= 500)
            {
                strncat(buffer, prefixInfo, strlen(prefixInfo));
            }
            else
            {
				printf("Too long data:len(%d) buffer:(%s)\r\n",strlen(buffer),buffer);
            }
        }

        for(uint32_t i = 0; i < dataLen; i++)
        {
            snprintf(str, 6, "%02X ", *(pData + i));
            printf("test:(%s)len(%d)\r\n",str,strlen(str));
			//sprintf(str, "%X ", *(pData + i));
            strncat(buffer, str, 3);
        }
		printf("%d(%s)(%d)\r\n",dataLen,buffer,strlen(buffer));
    }
}

int main()
{
	uint8_t test[10]={0x0a,0xbb,0xcc,0xdd,0xee,0xff};
 	DiagR_BufferPrint("testbuffer:",test,3);

   return 0;
}





vae@vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU:~/qpOASES$ make SHARED=yes Creating /home/vae/qpOASES/src/LAPACKReplacement.o Creating /home/vae/qpOASES/src/BLASReplacement.o Creating SQProblem.o SQProblem.cpp: In member function ‘qpOASES::returnValue qpOASES::SQProblem::hotstart(qpOASES::SymmetricMatrix*, const real_t*, qpOASES::Matrix*, const real_t*, const real_t*, const real_t*, const real_t*, qpOASES::int_t&, qpOASES::real_t*, const qpOASES::Bounds*, const qpOASES::Constraints*)’: SQProblem.cpp:116:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 116 | if ( cputime != 0 ) | ^~ SQProblem.cpp:121:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 121 | if ( setupNewAuxiliaryQP( H_new,A_new,lb_new,ub_new,lbA_new,ubA_new ) != SUCCESSFUL_RETURN ) | ^~ SQProblem.cpp: In member function ‘qpOASES::returnValue qpOASES::SQProblem::hotstart(const real_t*, const real_t*, const real_t*, const real_t*, const real_t*, const real_t*, const real_t*, qpOASES::int_t&, qpOASES::real_t*, const qpOASES::Bounds*, const qpOASES::Constraints*)’: SQProblem.cpp:165:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 165 | if ( cputime != 0 ) | ^~ SQProblem.cpp:170:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 170 | if ( setupNewAuxiliaryQP( H_new,A_new,lb_new,ub_new,lbA_new,ubA_new ) != SUCCESSFUL_RETURN ) | ^~ Creating QProblem.o QProblem.cpp: In member function ‘qpOASES::returnValue qpOASES::QProblem::updateFarBounds(qpOASES::real_t, qpOASES::int_t, const real_t*, qpOASES::real_t*, const real_t*, qpOASES::real_t*, const real_t*, qpOASES::real_t*, const real_t*, qpOASES::real_t*) const’: QProblem.cpp:5483:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 5483 | if ( returnvalue != SUCCESSFUL_RETURN ) | ^~ QProblem.cpp:5486:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 5486 | if ( options.enableRamping == BT_TRUE ) | ^~ QProblem.cpp: In member function ‘qpOASES::returnValue qpOASES::QProblem::printIteration(qpOASES::int_t, qpOASES::int_t, qpOASES::SubjectToStatus, qpOASES::BooleanType, qpOASES::real_t, qpOASES::BooleanType)’: QProblem.cpp:6213:76: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size between 119 and 135 [-Wformat-truncation=] 6213 | snprintf( myPrintfString,MAX_STRING_LENGTH," %5.1d | %1.6e | %s %4.1d | %4.1d | %4.1d \n", (int)iter,tau,info,(int)BC_idx,(int)getNFX( ),(int)getNAC( ) ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Indexlist.hpp:40, from /home/vae/qpOASES/include/qpOASES/SubjectTo.hpp:40, from /home/vae/qpOASES/include/qpOASES/Bounds.hpp:40, from /home/vae/qpOASES/include/qpOASES/Flipper.hpp:40, from /home/vae/qpOASES/include/qpOASES/QProblemB.hpp:42, from /home/vae/qpOASES/include/qpOASES/QProblem.hpp:41, from QProblem.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 55 and 251 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ QProblem.cpp:6198:78: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size between 118 and 134 [-Wformat-truncation=] 6198 | snprintf( myPrintfString,MAX_STRING_LENGTH," %5.1d* | %1.6e | %s SOLVED | %4.1d | %4.1d \n", (int)iter,tau,info,(int)getNFX( ),(int)getNAC( ) ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Indexlist.hpp:40, from /home/vae/qpOASES/include/qpOASES/SubjectTo.hpp:40, from /home/vae/qpOASES/include/qpOASES/Bounds.hpp:40, from /home/vae/qpOASES/include/qpOASES/Flipper.hpp:40, from /home/vae/qpOASES/include/qpOASES/QProblemB.hpp:42, from /home/vae/qpOASES/include/qpOASES/QProblem.hpp:41, from QProblem.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 60 and 249 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ QProblem.cpp:6196:78: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size between 118 and 134 [-Wformat-truncation=] 6196 | snprintf( myPrintfString,MAX_STRING_LENGTH," %5.1d | %1.6e | %s SOLVED | %4.1d | %4.1d \n", (int)iter,tau,info,(int)getNFX( ),(int)getNAC( ) ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Indexlist.hpp:40, from /home/vae/qpOASES/include/qpOASES/SubjectTo.hpp:40, from /home/vae/qpOASES/include/qpOASES/Bounds.hpp:40, from /home/vae/qpOASES/include/qpOASES/Flipper.hpp:40, from /home/vae/qpOASES/include/qpOASES/QProblemB.hpp:42, from /home/vae/qpOASES/include/qpOASES/QProblem.hpp:41, from QProblem.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 60 and 249 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Creating QProblemB.o QProblemB.cpp: In member function ‘qpOASES::returnValue qpOASES::QProblemB::changeActiveSet(qpOASES::int_t, qpOASES::SubjectToStatus)’: QProblemB.cpp:3380:4: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation] 3380 | else | ^~~~ QProblemB.cpp:3382:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’ 3382 | getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNC__,__FILE__,__LINE__,VS_VISIBLE ); | ^~~~~~~~~~~~~~~~~~~~~~~ QProblemB.cpp: In member function ‘qpOASES::returnValue qpOASES::QProblemB::printIteration(qpOASES::int_t, qpOASES::int_t, qpOASES::SubjectToStatus, qpOASES::real_t, qpOASES::BooleanType)’: QProblemB.cpp:3828:76: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size between 119 and 135 [-Wformat-truncation=] 3828 | snprintf( myPrintfString,MAX_STRING_LENGTH," %5.1d | %1.6e | %s %4.1d | %4.1d \n", (int)iter,tau,info,(int)BC_idx,(int)getNFX( ) ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Indexlist.hpp:40, from /home/vae/qpOASES/include/qpOASES/SubjectTo.hpp:40, from /home/vae/qpOASES/include/qpOASES/Bounds.hpp:40, from /home/vae/qpOASES/include/qpOASES/Flipper.hpp:40, from /home/vae/qpOASES/include/qpOASES/QProblemB.hpp:42, from QProblemB.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 45 and 234 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ QProblemB.cpp:3818:78: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size between 118 and 134 [-Wformat-truncation=] 3818 | snprintf( myPrintfString,MAX_STRING_LENGTH," %5.1d* | %1.6e | %s SOLVED | %4.1d \n", (int)iter,tau,info,(int)getNFX( ) ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Indexlist.hpp:40, from /home/vae/qpOASES/include/qpOASES/SubjectTo.hpp:40, from /home/vae/qpOASES/include/qpOASES/Bounds.hpp:40, from /home/vae/qpOASES/include/qpOASES/Flipper.hpp:40, from /home/vae/qpOASES/include/qpOASES/QProblemB.hpp:42, from QProblemB.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 50 and 232 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ QProblemB.cpp:3816:78: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size between 118 and 134 [-Wformat-truncation=] 3816 | snprintf( myPrintfString,MAX_STRING_LENGTH," %5.1d | %1.6e | %s SOLVED | %4.1d \n", (int)iter,tau,info,(int)getNFX( ) ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Indexlist.hpp:40, from /home/vae/qpOASES/include/qpOASES/SubjectTo.hpp:40, from /home/vae/qpOASES/include/qpOASES/Bounds.hpp:40, from /home/vae/qpOASES/include/qpOASES/Flipper.hpp:40, from /home/vae/qpOASES/include/qpOASES/QProblemB.hpp:42, from QProblemB.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 50 and 232 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Creating SQProblemSchur.o Creating Bounds.o Creating Constraints.o Creating SubjectTo.o Creating Indexlist.o Creating Flipper.o Creating Utils.o Creating Options.o Options.cpp: In member function ‘qpOASES::returnValue qpOASES::Options::print() const’: Options.cpp:386:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 386 | snprintf( myPrintfString,MAX_STRING_LENGTH,"printLevel = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:392:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 392 | snprintf( myPrintfString,MAX_STRING_LENGTH,"enableRamping = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:396:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 396 | snprintf( myPrintfString,MAX_STRING_LENGTH,"enableFarBounds = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:400:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 400 | snprintf( myPrintfString,MAX_STRING_LENGTH,"enableFlippingBounds = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:404:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 404 | snprintf( myPrintfString,MAX_STRING_LENGTH,"enableRegularisation = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:408:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 408 | snprintf( myPrintfString,MAX_STRING_LENGTH,"enableFullLITests = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:412:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 412 | snprintf( myPrintfString,MAX_STRING_LENGTH,"enableNZCTests = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:422:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 422 | snprintf( myPrintfString,MAX_STRING_LENGTH,"enableEqualities = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:426:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 426 | snprintf( myPrintfString,MAX_STRING_LENGTH,"enableInertiaCorrection = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Options.cpp:470:80: warning: ‘%s’ directive output may be truncated writing up to 159 bytes into a region of size 126 [-Wformat-truncation=] 470 | snprintf( myPrintfString,MAX_STRING_LENGTH,"initialStatusBounds = %s\n",info ); | ^~ ~~~~ In file included from /usr/include/stdio.h:867, from /home/vae/qpOASES/include/qpOASES/MessageHandling.hpp:39, from /home/vae/qpOASES/include/qpOASES/Utils.hpp:39, from /home/vae/qpOASES/include/qpOASES/Options.hpp:40, from Options.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 36 and 195 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Creating Matrices.o Creating MessageHandling.o MessageHandling.cpp: In member function ‘qpOASES::returnValue qpOASES::MessageHandling::throwMessage(qpOASES::returnValue, const char*, const char*, const char*, long unsigned int, qpOASES::VisibilityStatus, const char*)’: MessageHandling.cpp:517:50: warning: ‘->’ directive output may be truncated writing 2 bytes into a region of size between 1 and 160 [-Wformat-truncation=] 517 | snprintf( myPrintfString,MAX_STRING_LENGTH,"%s->", whitespaces ); | ^~ In file included from /usr/include/stdio.h:867, from MessageHandling.cpp:36: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 3 and 162 bytes into a destination of size 160 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Creating SparseSolver.o Creating SolutionAnalysis.o Creating OQPinterface.o Creating static lib /home/vae/qpOASES/bin/libqpOASES.a ar: 正在创建 /home/vae/qpOASES/bin/libqpOASES.a Creating shared lib /home/vae/qpOASES/bin/libqpOASES.so Creating example1.o Creating /home/vae/qpOASES/bin/example1 Creating example1a.o Creating /home/vae/qpOASES/bin/example1a Creating example1b.o Creating /home/vae/qpOASES/bin/example1b Creating example2.o Creating /home/vae/qpOASES/bin/example2 Creating example3.o Creating /home/vae/qpOASES/bin/example3 Creating example3b.o Creating /home/vae/qpOASES/bin/example3b Creating example4.o Creating /home/vae/qpOASES/bin/example4 Creating example5.o Creating /home/vae/qpOASES/bin/example5 Creating exampleLP.o Creating /home/vae/qpOASES/bin/exampleLP Creating qrecipe.o Creating /home/vae/qpOASES/bin/qrecipe Creating qrecipeSchur.o Creating /home/vae/qpOASES/bin/qrecipeSchur vae@vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU:~/qpOASES$ make python cd ./interfaces/python/ && python3 setup.py build_ext --inplace Compiling qpoases.pyx because it changed. [1/1] Cythonizing qpoases.pyx Error compiling Cython file: ------------------------------------------------------------ ... np.ndarray[np.double_t, ndim=1] maxStat, np.ndarray[np.double_t, ndim=1] maxFeas, np.ndarray[np.double_t, ndim=1] maxCmpl ): cdef real_t ret # 统一使用qpOASES::real_t ret = self.thisptr->getKktViolation( ^ ------------------------------------------------------------ qpoases.pyx:811:26: Syntax error in simple statement list Traceback (most recent call last): File "setup.py", line 27, in <module> ext_modules=cythonize(ext_modules, language_level=3), # 指定Python 3语法 File "/home/vae/.local/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1115, in cythonize cythonize_one(*args) File "/home/vae/.local/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1238, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: qpoases.pyx make: *** [Makefile:80:python] 错误 1
最新发布
07-11
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值