Skip to content

Fix error C2020: 'parms': 'struct' member redefinition - #91

Merged
andywolk merged 1 commit into
masterfrom
windowsfix
Jul 30, 2026
Merged

Fix error C2020: 'parms': 'struct' member redefinition#91
andywolk merged 1 commit into
masterfrom
windowsfix

Conversation

@andywolk

@andywolk andywolk commented Feb 5, 2025

Copy link
Copy Markdown
Member

No description provided.

@andywolk andywolk added the bug Something isn't working label Feb 5, 2025
@coppice-git

Copy link
Copy Markdown
Collaborator

I don't know why the Windows compiler might be complaining about this, but the suggested patch is an ugly way to deal with the problem. I'll produce something cleaner.

@coppice-git

Copy link
Copy Markdown
Collaborator

I just checked out the spandsp repo on a Windows 11 PC with Visual Studio 2022. I compile and do not see the C2020 error. Is this error with a different version of Visual Studio?

@andywolk

andywolk commented Feb 6, 2025

Copy link
Copy Markdown
Member Author

@coppice-git
This is when FreeSWITCH is compiled against SpanDSP master on Windows.
There is a branch that you can clone and try building. You will see those errors:
https://github.com/signalwire/freeswitch/commits/spandspwindows/

@andywolk

andywolk commented Feb 6, 2025

Copy link
Copy Markdown
Member Author

and yes Visual Studio 2022 is the main version to use.

@andywolk

Copy link
Copy Markdown
Member Author

@coppice-git SpanDSP headers are broken to use on Windows without this PR. Therefore no way to use the latest SpanDSP master.

@andywolk

andywolk commented Sep 9, 2025

Copy link
Copy Markdown
Member Author

@coppice-git ping

@andywolk

Copy link
Copy Markdown
Member Author

@coppice-git See if you like this more

@github-actions

Copy link
Copy Markdown

⚠️ Scan-Build has detected potential issues.

View the scan-build logs here: https://github.com/freeswitch/spandsp/actions/runs/30476949144/artifacts/8734087507

@pbogosian-ccs

pbogosian-ccs commented Jul 29, 2026

Copy link
Copy Markdown

I fixed this on 4/2/2025 with the 2 lines below. This is an obvious problem to any senior engineer with MS C compiler experience (your comments and change in the code are correct):
#undef near
#undef far
Another solution would be to change from using near/far as variable names. I didn't want to make these massive changes.

@github-actions

Copy link
Copy Markdown

⚠️ Scan-Build has detected potential issues.

View the scan-build logs here: https://github.com/freeswitch/spandsp/actions/runs/30493216737/artifacts/8740621356

@briankwest
briankwest self-requested a review July 30, 2026 15:04
  <windows.h> (shared/minwindef.h) defines the legacy 16 bit memory model
  keywords "near" and "far" as empty macros. In any translation unit that
  includes it ahead of spandsp/expose.h, that strips the names from the near
  and far members of struct v150_1_state_s:

      struct { v150_1_near_far_t parms; ... } ;   /* was } near; */
      struct { v150_1_near_far_t parms; ... } ;   /* was } far;  */

  MSVC then treats both as anonymous structs and flattens their members into
  the enclosing struct, where the two "parms" members collide. The error names
  "parms" rather than near/far because those tokens are gone before the
  compiler sees them.

  Undefine both macros around the struct in private/v150_1.h, restoring them
  with #pragma pop_macro at the end of the header. private/v150_1.h is an
  installed header, so it must not leave a consumer's macro state altered.
  v150_1.c refers to the members by name and is the only file that does, so it
  undefines the macros locally after its includes.
@github-actions

Copy link
Copy Markdown

⚠️ Scan-Build has detected potential issues.

View the scan-build logs here: https://github.com/freeswitch/spandsp/actions/runs/30571174377/artifacts/8770913226

@andywolk
andywolk merged commit f3e33a1 into master Jul 30, 2026
13 of 14 checks passed
@andywolk
andywolk deleted the windowsfix branch July 30, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants