Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1105617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:39:39+00:00 2026-05-17T01:39:39+00:00

I have a function uint8_t EE_Write(uint8_t addr, uint8_t len, uint8_t * buf) that takes

  • 0

I have a function uint8_t EE_Write(uint8_t addr, uint8_t len, uint8_t * buf) that takes a pointer to some data that it will write to memory, and a uint16_t myword that I want to give it. The basic

EE_Write(0,sizeof(myword),&myword);

gives me the compiler warning “Indirection to different types (‘unsigned int *const ‘ instead of ‘unsigned char *const ‘)” Even when I typecast the word (int) to a byte (char), I received the exact same warning (and no amount of grouping with parenthesis helped).

EE_Write(0,sizeof(myword),&(uint8_t)myword);

Warnings go away with a union, but it’s asinine to have to write it to another variable just to make the compiler happy.

union catbyte {
    uint16_t w;
    uint8_t b[2];
};

union catbyte mybytes;

mybytes.w = myword;
EE_Write(0,sizeof(myword),mybytes.b);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:39:40+00:00Added an answer on May 17, 2026 at 1:39 am

    You could do:

    EE_Write(0,sizeof(myword),(uint8_t *)&myword);
    

    But the prefered way of doing this would be to define the function to take a void pointer like:

    uint8_t EE_Write(uint8_t addr, uint8_t len, const void * buf);
    

    And then the compiler shouldn’t warn you about it for any pointer type you pass.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have strings like uint8_t char[5] int[3] How can I write a short function
I have function getCartItems in cart.js and I want to call that function in
I have function Start() that is fired on ready. When I click on .ExampleClick
I have function some_func_1 which will create an object of type some_type and will
I have a function where I will compress a bunch of files into a
I have a question about pointer casting for C. if I have a function
I have a kernel module that allocates a large buffer of memory, this buffer
I currently have a piece of code that I am working on using function
I have this function which uses SSE2 to add some values together it's supposed
I have the following code that calls the function uint32_pack. This program compiles with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.