Skip to content

Commit b4222b1

Browse files
committed
"using namespace" should not be in in header File
this can give problems that can not be worked around by the code that is using the library removed from SD.h and added to file.cpp and examples
1 parent c635295 commit b4222b1

File tree

8 files changed

+14
-2
lines changed

8 files changed

+14
-2
lines changed

examples/Datalogger/Datalogger.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <SPI.h>
2727
#include <SD.h>
2828

29+
using namespace SDLib;
30+
2931
const int chipSelect = 10;
3032

3133
void setup() {

examples/DumpFile/DumpFile.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
const int chipSelect = 10;
2727

28+
using namespace SDLib;
29+
2830
void setup() {
2931
// Open serial communications and wait for port to open:
3032
Serial.begin(9600);

examples/Files/Files.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
#include <SD.h>
2323

24+
using namespace SDLib;
25+
2426
const int chipSelect = 10;
2527
File myFile;
2628

examples/NonBlockingWrite/NonBlockingWrite.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
*/
3434
#include <SD.h>
3535

36+
using namespace SDLib;
37+
3638
const int chipSelect = 10;
3739

3840
// file name to use for writing

examples/ReadWrite/ReadWrite.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
#include <SD.h>
2222

23+
using namespace SDLib;
24+
2325
const int chipSelect = 10;
2426
File myFile;
2527

examples/listfiles/listfiles.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
*/
2929
#include <SD.h>
3030

31+
using namespace SDLib;
32+
3133
const int chipSelect = 10;
3234
File root;
3335

src/File.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
uint8_t nfilecount=0;
1919
*/
2020

21+
using namespace SDLib;
22+
2123
File::File(SdFile f, const char *n) {
2224
// oh man you are kidding me, new() doesn't exist? Ok we do it by hand!
2325
_file = (SdFile *)malloc(sizeof(SdFile));

src/SD.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ namespace SDLib {
126126
// We enclose File and SD classes in namespace SDLib to avoid conflicts
127127
// with others legacy libraries that redefines File class.
128128

129-
// This ensure compatibility with sketches that uses only SD library
130-
using namespace SDLib;
131129

132130
// This allows sketches to use SDLib::File with other libraries (in the
133131
// sketch you must use SDFile instead of File to disambiguate)

0 commit comments

Comments
 (0)