From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 05D4B3858413 for ; Mon, 16 Aug 2021 11:55:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 05D4B3858413 Received: by mail-wm1-x32c.google.com with SMTP id q11-20020a7bce8b0000b02902e6880d0accso14828380wmj.0 for ; Mon, 16 Aug 2021 04:55:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=d4uniJqP7rV469uL9v/lAhJ3DjXSzysr/GBBMUpQQU4=; b=n0OtkAzhtyka0bnb2ioLJvwAac9AznpAMDH3WLXR+RjGgqGYt+bzWaMT2BTGo7hiAO FcrLyZyaQUsLNMOXZblEn0G0pAa2WWG538wVxPZh43qTReCLaCu7ETH0mfudZhT3xqqa Jj3HcUtNt9NBiF26UIVqgZ4GPcijSC6RPJubG+4R58JDsoy9y6FjZmTAH1HTOqQ918Xl 2wCPnAcSD+lm0303pXDXX2RMFnlAFAYLjbbcTFWOC9UbtYSJOFlycBfwaWtA2tMgnpID d53X0Az0pnzRgICo70K8Of+GPcF9329Pqag4dW9JEH0+m2CSIfZBeYIOQJ9m/QNj0Uj3 Vd0w== X-Gm-Message-State: AOAM530w/XsV3HrTQSKWxy7doQc7jm8ObVn1oVM7CvTNZbMncSUVs8Bs KA12IAAIoyiOsyz/qDBiO6SLO9UobVYjGE3aGzS7gfyEP7o= X-Google-Smtp-Source: ABdhPJx7A7ZXXdCrsoNj9phedS+Ig0B/nIxa1QGXFD5K9zVfnHM7KJbJpWq73cw+KLpYzHlqTFA9uJu8anUfGIHngpQ= X-Received: by 2002:a05:600c:c2:: with SMTP id u2mr14836074wmm.106.1629114950819; Mon, 16 Aug 2021 04:55:50 -0700 (PDT) MIME-Version: 1.0 From: Jonathan Wakely Date: Mon, 16 Aug 2021 12:55:39 +0100 Message-ID: Subject: What should a std::error_code pretty printer show? To: "libstdc++" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Aug 2021 11:55:53 -0000 I'm adding a GDB printer for std::error_code.What I have now prints the category name as a quoted string, followed by the error value: {"system": 0} {"system": 1234} If the category is std::generic_category() then it also shows the strerror description: {"generic": 13 "Permission denied"} But I'd also like it to show the errno macro, but I'm not sure what's the best way to show it. Does this seem OK? {"generic": 13 EACCES "Permission denied"} I think that's a bit too verbose. Would {"generic": EACCES} be better? You can always use ec.value() to get the numeric value, and strerror to get the description if you want those.