CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Baffled by a compiler ierror in VS2019

    I'm trying to move a large project (previously built with VS2005) and update it all to VS2019. One of the header files contains these enums:-

    Code:
    typedef enum {
    	WT_NONE,
    	/* warcinfo */
    	WT_INFO,
    	/* metadata */
    	WT_META,
    	/* resource */
    	WT_RSRC,
    	/* request, unsupported */
    	WT_REQ,
    	/* response, unsupported */
    	WT_RSP,
    	/* revisit, unsupported */
    	WT_RVIS,
    	/* conversion, unsupported */
    	WT_CONV,
    	/* continutation, unsupported at the moment */
    	WT_CONT,
    	/* invalid type */
    	LAST_WT
    } warc_type_t
    and a source file handles them, like so_-

    Code:
    switch (ftyp) {
    case WT_RSRC:
    case WT_RSP:
    	/* only try and read the filename in the cases that are
    	 * guaranteed to have one */
    	fnam = _warc_rduri(buf, eoh - buf);
    	/* check the last character in the URI to avoid creating
    	 * directory endpoints as files, see Todo above */
    	if (fnam.len == 0 || fnam.str[fnam.len - 1] == '/') {
    		/* break here for now */
    		fnam.len = 0U;
    		fnam.str = NULL;
    		break;
    	}
    	/* bang to our string pool, so we save a
    	 * malloc()+free() roundtrip */
    	if (fnam.len + 1U > w->pool.len) {
    		w->pool.len = ((fnam.len + 64U) / 64U) * 64U;
    		w->pool.str = realloc(w->pool.str, w->pool.len);
    	}
    	memcpy(w->pool.str, fnam.str, fnam.len);
    	w->pool.str[fnam.len] = '\0';
    	/* let no one else know about the pool, it's a secret, shhh */
    	fnam.str = w->pool.str;
    
    	/* snarf mtime or deduce from rtime
    	 * this is a custom header added by our writer, it's quite
    	 * hard to believe anyone else would go through with it
    	 * (apart from being part of some http responses of course) */
    	if ((mtime = _warc_rdmtm(buf, eoh - buf)) == (time_t)-1) {
    		mtime = rtime;
    	}
    	break;
    default:
    	fnam.len = 0U;
    	fnam.str = NULL;
    	break;
    }
    but whenever I try to build the source file I get these compiler errors:-

    Code:
    error C4061: enumerator 'WT_NONE' in switch of enum 'warc_type_t' is not explicitly handled by a case label
    and I get identical errors for all the other unhandled ones (WT_INFO / WT_META / WT_REQ etc). Does this make sense to anyone? Surely the unspecified ones should just get passed to default:
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Baffled by a compiler ierror in VS2019

    I found it !!!

    Under the C/C++ -> Command line properties there was an entry saying /we4061 (which treats that particular warning as an error!) I've no idea why it never showed up previously in VS2005...
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Baffled by a compiler ierror in VS2019

    C4061 is usually a warning only at L4. Are you treating warnings as errors? See https://docs.microsoft.com/en-us/cpp...?view=msvc-160
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Baffled by a compiler ierror in VS2019

    Thanks 2kaud - I just beat you to it !
    "A problem well stated is a problem half solved.” - Charles F. Kettering

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured