Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many warnings for when defined #1704

Closed
PavelVozenilek opened this issue Dec 5, 2014 · 3 comments
Closed

Too many warnings for when defined #1704

PavelVozenilek opened this issue Dec 5, 2014 · 3 comments

Comments

@PavelVozenilek
Copy link
Contributor

Current 0.10 compiler issues a warning for every location where when defined is not found true.

Example:

proc foo =
  echo "foo"
  when defined (x): echo "x"
  when defined (x): echo "x"
  when defined (x): echo "x"
  when defined (x): echo "x"
  when defined (x): echo "x"

foo()

Compiler output:

C:\Nimrod\bin>nim c a.nim
c:\nimrod\config\nim.cfg(42, 2) Hint: added path: 'C:\Users\U┼żivatel\.babel\pkgs\babel-0.4.0' [Path]
c:\nimrod\config\nim.cfg(42, 2) Hint: added path: 'C:\Users\U┼żivatel\.babel\pkgs\' [Path]
c:\nimrod\config\nim.cfg(43, 2) Hint: added path: 'C:\Users\U┼żivatel\.nimble\pkgs\' [Path]
Hint: used config file 'C:\Nimrod\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: a [Processing]
a.nim(3, 15) Warning: undeclared conditional symbol; use --symbol to declare it: x [User]
a.nim(4, 15) Warning: undeclared conditional symbol; use --symbol to declare it: x [User]
a.nim(5, 15) Warning: undeclared conditional symbol; use --symbol to declare it: x [User]
a.nim(6, 15) Warning: undeclared conditional symbol; use --symbol to declare it: x [User]
a.nim(7, 15) Warning: undeclared conditional symbol; use --symbol to declare it: x [User]
gcc.exe -c  -w  -IC:\Nimrod\lib -o c:\nimrod\bin\nimcache\a.o c:\nimrod\bin\nimcache\a.c
gcc.exe   -o c:\nimrod\bin\a.exe  c:\nimrod\bin\nimcache\stdlib_system.o c:\nimrod\bin\nimcache\a.o
Hint: operation successful (8869 lines compiled; 0.472 sec total; 15.153MB) [SuccessX]

C:\Nimrod\bin>

All five instances of when defined produce their own warning. What is --symbol doing here is not clear to me. The documentation gives no hint why this cmdline option even exists, what is wrong with --define.

Perhaps only the first generated warning should be shown.

A pragma/cmdline option to get rid of individual warnings would be also useful.

@jovial
Copy link
Contributor

jovial commented Dec 5, 2014

you can do:

proc foo =
  echo "foo"
  {.push warning[user]: off}
  when defined (x): echo "x"
  when defined (x): echo "x"
  when defined (x): echo "x"
  when defined (x): echo "x"
  when defined (x): echo "x"
  {.pop.}

foo()

maybe worth putting in a template if you use it often.

@PavelVozenilek
Copy link
Contributor Author

This works for my code.

The docs could an example.

I am closing the issue.

@superfunc
Copy link
Contributor

Why not make a PR to the docs then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants