Skip to content

Wont compile - "passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]" #2

@bencoton

Description

@bencoton

Can you please help with the code? I am having multiple failures however the failure in the title seems to be the greatest failure.

I am using Arduino IDE 1.8.19

In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.cpp:13:0:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'int32_t LoadCell::ReadARawValue() const':
LoadCell.h:336:50: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
int32_t ReadARawValue() const { return read(); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.cpp:13:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.cpp:13:0:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'double LoadCell::ReadARawValueD() const':
LoadCell.h:337:70: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
double ReadARawValueD() const { return static_cast(read()); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.cpp:13:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.cpp: In constructor 'LoadCell::LoadCell(int, int, uint8_t)':
LoadCell.cpp:49:26: error: no matching function for call to 'LoadCell::begin(int&, int&, uint8_t&)'
begin(dout, sck, gain);
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.cpp:13:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:38:12: note: candidate: void HX711::begin(uint8_t, uint8_t)
void begin(uint8_t dataPin, uint8_t clockPin);
^
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:38:12: note: candidate expects 2 arguments, 3 provided
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.cpp: In member function 'bool LoadCell::IsPresent() const':
LoadCell.cpp:142:35: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
if (!wait_ready_retry(10U, 10U) || (ReadARawValue() == 0L))
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.cpp:13:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:49:12: note: in call to 'bool HX711::wait_ready_retry(uint8_t, uint32_t)'
bool wait_ready_retry(uint8_t retries = 3, uint32_t ms = 0);
^
At global scope:
cc1plus.exe: warning: unrecognized command line option '-Wno-frame-address'
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.cpp:14:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'int32_t LoadCell::ReadARawValue() const':
LoadCell.h:336:50: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
int32_t ReadARawValue() const { return read(); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.cpp:14:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.cpp:14:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'double LoadCell::ReadARawValueD() const':
LoadCell.h:337:70: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
double ReadARawValueD() const { return static_cast(read()); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.cpp:14:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:18:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\HslColor.cpp:14:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Save() const':
SpoolManager.h:406:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:407:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Restore()':
SpoolManager.h:460:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:461:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Reset()':
SpoolManager.h:498:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:499:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\MainScreen.cpp:12:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'int32_t LoadCell::ReadARawValue() const':
LoadCell.h:336:50: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
int32_t ReadARawValue() const { return read(); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\MainScreen.cpp:12:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\MainScreen.cpp:12:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'double LoadCell::ReadARawValueD() const':
LoadCell.h:337:70: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
double ReadARawValueD() const { return static_cast(read()); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\MainScreen.cpp:12:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:18:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\MainScreen.cpp:12:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Save() const':
SpoolManager.h:406:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:407:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Restore()':
SpoolManager.h:460:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:461:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Reset()':
SpoolManager.h:498:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:499:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\Display.cpp:14:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'int32_t LoadCell::ReadARawValue() const':
LoadCell.h:336:50: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
int32_t ReadARawValue() const { return read(); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\Display.cpp:14:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\Display.cpp:14:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'double LoadCell::ReadARawValueD() const':
LoadCell.h:337:70: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
double ReadARawValueD() const { return static_cast(read()); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\Display.cpp:14:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.ino:53:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'int32_t LoadCell::ReadARawValue() const':
LoadCell.h:336:50: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
int32_t ReadARawValue() const { return read(); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.ino:53:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.ino:53:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h: In member function 'double LoadCell::ReadARawValueD() const':
LoadCell.h:337:70: error: passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]
double ReadARawValueD() const { return static_cast(read()); }
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\LoadCell.h:17:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:16,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.ino:53:
C:\Users\bcoto\OneDrive\Documents\Arduino\libraries\HX711/HX711.h:54:12: note: in call to 'float HX711::read()'
float read();
^
In file included from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.h:18:0,
from C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\JmcFilamentScale.ino:53:
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Save() const':
SpoolManager.h:406:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:407:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
At global scope:
cc1plus.exe: warning: unrecognized command line option '-Wno-frame-address'
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Restore()':
SpoolManager.h:460:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:461:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\SpoolManager.h: In member function 'bool SpoolManager::Reset()':
SpoolManager.h:498:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
SpoolManager.h:499:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\MainScreen.cpp: In static member function 'static bool MainScreen::Save()':
MainScreen.cpp:370:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
MainScreen.cpp:371:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\MainScreen.cpp: In static member function 'static bool MainScreen::Restore()':
MainScreen.cpp:416:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
MainScreen.cpp:417:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
C:\Users\bcoto\OneDrive\Desktop\Filament Scale\Filament-Scale-main\SourceFiles\JmcFilamentScale\MainScreen.cpp: In static member function 'static bool MainScreen::Reset()':
MainScreen.cpp:465:9: error: 'Preferences' was not declared in this scope
Preferences prefs;
^
MainScreen.cpp:466:9: error: 'prefs' was not declared in this scope
prefs.begin(m_pName);
^
At global scope:
cc1plus.exe: warning: unrecognized command line option '-Wno-frame-address'
At global scope:
cc1plus.exe: warning: unrecognized command line option '-Wno-frame-address'
At global scope:
cc1plus.exe: warning: unrecognized command line option '-Wno-frame-address'
Multiple libraries were found for "WiFi.h"
Used: C:\Users\bcoto\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
passing 'const LoadCell' as 'this' argument discards qualifiers [-fpermissive]

Cheers,

Ben

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions