0

I am trying to write an i2c driver class. The class contains read() and write() methods. The problem is that I use write function of unistd.h in my Drv_i2c class write() function (see below) and Qtcreator compiler chooses my class write function instead of unistd.h write function.

I know that I could just rename my class function but is it possible to specify that I want to use unistd.h write function? (Same for read function)

    bool Drv_i2c::write(uint8_t p_i2c_address, uint8_t p_reg, const std::vector<uint8_t> 
    &p_data)
    {
        [...]

        /* Checking that all data has been written */
        if(write(this->s_fd_i2c, l_buffer, l_buf_length) != l_buf_length)
        {
            //  ERROR HANDLING: i2c transaction failed
            l_result = false;
        }
        [...]
    }
Fareanor
  • 5,900
  • 2
  • 11
  • 37
Lizzie49
  • 3
  • 2
  • 3
    Just use a qualified name? `::write` – user17732522 Sep 20 '22 at 09:58
  • This is explained in any beginner [c++ book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) and various SO posts. For example, [Why does C++ need the scope resolution operator?](https://stackoverflow.com/questions/9338217/why-does-c-need-the-scope-resolution-operator) – Jason Sep 20 '22 at 11:26

1 Answers1

0

You can use the scope operator "::" maybe

Nikihacker
  • 26
  • 2