zoukankan      html  css  js  c++  java
  • unable to find string literal operator ‘operator""format’ with ‘const char [10]’, ‘long unsigned int’ arguments

    简介

    遇到问题

    unable to find string literal operator ‘operator""format’ with ‘const char [10]’, ‘long unsigned int’ arguments
     #define DEBUG_(format,...) printf("[DEBUG] "format"
    ", ##__VA_ARGS__)
    

    参考链接

    https://blog.csdn.net/q2519008/article/details/80934815

    Result

    可能是因为C++11或者更高的标准更改了编译操作参考链接
    https://en.cppreference.com/w/cpp/language/user_literal
    其中" 引号也是一个可以重载的操作符。没有string和long unsigned int结合的操作符。

    TODO

    #define DEBUG_(format,...) printf("[DEBUG] "format"
    ", ##__VA_ARGS__)
    

    替换为宏函数

    /*
     * @Author: your name
     * @Date: 2020-12-02 09:06:35
     * @LastEditTime: 2020-12-02 13:59:54
     * @LastEditors: Please set LastEditors
     * @Description: In User Settings Edit
     * @FilePath: /my_skel/header/debug.hpp
     */
    #ifndef __DEBUG_HPP__
    #define __DEBUG_HPP__
    #include <cstdio>
    #include <string>
    #include <iostream>
    
    //#define __TT__
    
    // #ifdef __TT__
    // #define ERROR_D(...) 
    // do{ 
    //     fprintf(stderr, "[ERROR  ]%s %s(Line %d): ",__FILE__,__FUNCTION__,__LINE__); 
    //     fprintf(stderr, __VA_ARGS__); 
    // }while(0)
    // #else
    // #define ERROR_D(...)
    // #endif
    
    // #ifdef __TT__
    // #define WARNING_D(...) 
    // do{ 
    //     fprintf(stdout, "[WARNING]%s %s(Line %d): ",__FILE__,__FUNCTION__,__LINE__); 
    //     fprintf(stdout, __VA_ARGS__); 
    // }while(0)
    // #else
    // #define WARNING_D(...)
    // #endif
    
    
    // #ifdef __TT__
    // #define INFO_D(...) 
    //     do{ 
    //         fprintf(stdout, "[INFO  ]%s %s(Line %d): ",__FILE__,__FUNCTION__,__LINE__); 
    //         fprintf(stdout, __VA_ARGS__); 
    //     }while(0)
    // #else
    // #define INFO_D(...)
    // #endif
    
    
    #ifdef __TT__
    #define DBG_D(format,...)
    do{ 
        std::string tout_xxdafdsaf="[DEBUG] "; 
        tout_xxdafdsaf += (std::string)format; 
        printf(tout_xxdafdsaf.c_str(), ##__VA_ARGS__); 
    }while(0)
    #else
    #define DBG_D(format,...) 
        do{ 
        }while(0)
    #endif
    
    
    #ifdef __TT__
    #define DBG_S(...)
    do{ 
        std::cout << __VA_ARGS__; 
    }while(0) 
    #else
    #define DBG_S(...) 
        do{ 
        }while(0) 
    #endif
    
    
    // #ifdef __TT__
    // #define SHOW_TIME(...) 
    // do{
    //     extern unsigned long long gLatestTime;
    //     timeval tp;
    //     gettimeofday(&tp, NULL);
    //     unsigned long long now = tp.tv_sec*1000000+tp.tv_usec; 
    //     if(gLatestTime != 0) 
    //     { 
    //         fprintf(stdout, ">>>>>>>>>Used Time: %s[%d], %s: %ld.%ld, %llu ms ", __FILE__, __LINE__, __func__, tp.tv_sec, tp.tv_usec, (now-gLatestTime)/1000);
    //         fprintf(stdout, "/n"); 
    //     } 
    //     gLatestTime = now;
    // }while(0)  
    // #else
    // #define SHOW_TIME(...)
    // #endif
    
    #endif
    

    因为宏展开防止出现同名 使用了tout_xxdafdsaf这个

    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    HTTP 错误 404.13
    C# 文件操作(全部) 追加、拷贝、删除、移动文件、创建目录 修改文件名、文件夹名
    设计模式---装饰模式(Decorator)
    设计模式---订阅发布模式(Subscribe/Publish)
    Merge into 详细介绍
    优化案例--多语句表值函数的影响
    常用脚本--Kill所有连接到指定数据库上的回话
    常用脚本--查看当前锁信息
    常用脚本--查看死锁和阻塞usp_who_lock
    常用脚本--在线重建或重整实例下所有索引
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/14072090.html
Copyright © 2011-2022 走看看