CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

warning: [-Wunused-variable]

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 5, 2021, 10:21
Default warning: [-Wunused-variable]
  #1
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 9
mkhm is on a distinguished road
Hi foamers,
I have a solver and I used it for quite a while. It retrieve data from a table and read it and use it (I am 100% sure as I did some validations against experimental data). However, there was always this warning of [-Wunused-variable] occurring at compilation for the variable A in createfields.H :
Code:
tableParam tableObject("model",mesh);
const volScalarField& A = tableObject.getData("A");
I could not find any answer to my question. I found this post:
False warning: unused variable
It seems that the problem is coming from initialization. I changed the second line of the code in different ways but it did not help. So, I would be grateful if you can help me with this issue.
mkhm is offline   Reply With Quote

Old   February 26, 2022, 12:14
Default
  #2
New Member
 
Andrew Bickerdike
Join Date: Feb 2021
Posts: 6
Rep Power: 5
andrewbickerdike is on a distinguished road
Hi,

I'm having the same problem, have you since found a solution?
andrewbickerdike is offline   Reply With Quote

Old   February 26, 2022, 15:34
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
If the code looks OK, just ignore the warning and get on with other things.
andrewbickerdike likes this.
olesen is offline   Reply With Quote

Old   March 2, 2022, 06:58
Default
  #4
Member
 
Ali B.
Join Date: Mar 2020
Location: abzrg.github.io
Posts: 44
Rep Power: 6
reverseila is on a distinguished road
If you really want to get rid of it, just cast it to void.
Code:
tableParam tableObject("model",mesh);
const volScalarField& A = tableObject.getData("A");
(void) A;
With the last line, you are "using" A.
reverseila is offline   Reply With Quote

Reply

Tags
createfields.h, table data, [-wunused-variable]


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
foamToTecplot360 thomasduerr OpenFOAM Post-Processing 121 June 11, 2021 11:05
Caffa 3D code Waliur Rahman Main CFD Forum 0 May 29, 2018 01:53
[swak4Foam] installation problem with version 0.2.3 Claudio87 OpenFOAM Community Contributions 9 May 8, 2013 11:20
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 11:23


All times are GMT -4. The time now is 05:20.