Opened 8 years ago
Closed 5 years ago
#6601 closed enhancement (wontfix)
API: Make OGRFieldDefn * arg const in CreateField
Reported by: | Kurt Schwehr | Owned by: | Kurt Schwehr |
---|---|---|---|
Priority: | normal | Milestone: | closed_because_of_github_migration |
Component: | default | Version: | svn-trunk |
Severity: | normal | Keywords: | api |
Cc: | antonio |
Description
I think (but am not 100% sure) that we can make CreateField's poFieldDefn pointer const. e.g.
OGRErr OGRShapeLayer::CreateField( OGRFieldDefn *poFieldDefn, int bApproxOK ) // ogrsf_frmts/ogrsf_frmts.h virtual OGRErr CreateField( OGRFieldDefn *poField, int bApproxOK = TRUE );
would become
OGRErr OGRShapeLayer::CreateField( const OGRFieldDefn *poFieldDefn, int bApproxOK ) virtual OGRErr CreateField( const OGRFieldDefn *poField, int bApproxOK = TRUE );
There are a good number of places that need changes for this:
find . -name \*.h | xargs egrep ' CreateField[ (]' | wc -l 51
This would make life easier for static analyzers/optimizers.
There are many more like this, but this is the one I just hit.
Change History (5)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Eek. Undocumented side effects... no fun.
And yes, CPL_OVERRIDE is super important for catching nasty surprises.
comment:3 by , 6 years ago
Keywords: | api added |
---|---|
Summary: | Make OGRFieldDefn * arg const in CreateField → API: Make OGRFieldDefn * arg const in CreateField |
comment:4 by , 6 years ago
Cc: | added |
---|
comment:5 by , 5 years ago
Milestone: | → closed_because_of_github_migration |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.
I wouldn't be surprised that there are drivers that alter the passed object, for example when implementing name laundering, etc... I'm not completely clear what the desired behaviour would be.
Aside remark: we would likely need to tag with a CPL_OVERRIDE (that would expand to override in C++11) all overloaded methods so that signature changes can be easily detected.