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 8168331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:29:18+00:00 2026-06-06T20:29:18+00:00

I’m working with OpenGL shaders, which prefer C strings to NSStrings, and I’ve run

  • 0

I’m working with OpenGL shaders, which prefer C strings to NSStrings, and I’ve run into the following oddity:

The relevant facts are that

1) shaderSource is defined as

NSString* shaderSource

2) the signature of glShaderSource is

glShaderSource(GLuint shader, GLuint count, const GLchar** string, const GLint *length)

This works:

int len = [shaderSource length];
const char *cstr = [shaderSource UTF8String];
glShaderSource(shader, 1, &cstr, &len);

This does not work:

glShaderSource(shader, 1, &[shaderSource UTF8String], &[shaderSource length]);

I am clearly not understanding something about objective c here, and I’d like to rectify that problem, so if you’re so inclined, do pray tell, WTF?

  • 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-06-06T20:29:21+00:00Added an answer on June 6, 2026 at 8:29 pm

    You seem to be using &[shaderSource UTF8String] to give you an extra level of indirection, so that the types will be correct, since glShaderSource wants a pointer to a pointer. But you can’t just put & in front of anything to get a pointer to it.

    &x means “return the address of x”; for that to make sense, x must be a symbol, not an expression. You can’t write &[shaderSource UTF8String] for the same reason you can’t write &(1 + t). That’s just an expression, you need to store the value somewhere, only then you can pass along the address (place where you stored it).

    This might be confusing if you are used to C-structs, since if you have a struct foo with member bar, you can get the address of a member by writing &foo.bar. But Objective-C objects are not structs (well, technically they are opaque structs). You get property values from them by sending them messages, which is basically the same as a function call. So if foo is an object and bar is a property, &foo.bar (which is really short-hand for &[foo bar]) is an invalid expression.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.