I just wondered about this... I've never been in a library where you were allowed to take food or drinks inside.
Also, when I was in school, you couldn't go into the library whenever you wanted. You had to wait until scheduled time set up by a teacher so you could work on a specific project. If you wanted to go in there at the end of your lunch (after eating), you had to get permission in advance. That's the way all of my schools were.
My high school you could eat at the middle tables but only a brown bag lunch. The library was open all day and during lunch and an hour before and after school. The old lady who ran it was like a military drill instructor and she would mess you up bad if you messed with her rules or the books. This was in the late 1980s when your parents could sign a paper saying the school could whip your butt (and mine did).
When I was in jr high a friend and I would eat lunch in the library. She volunteered there after school and then started helping out at lunch time so she was allowed to. I often joined her to keep her company. This was in the late 80s and a small jr high school.
My friends and I would sometimes go and eat lunch in the library just to get away from the noise and crowds, especially during winter months when you didn't want to go outside. Probably a school by school basis. We didn't leave a mess, we didn't spill our drinks, weren't loud so they had no issues with it.
My small town high school had an "open lunch" policy (late 70s-early 80s) where we could leave the school and go to the McDonald's, the shopping center, go home, basically go anywhere as long as you were back for your next class, but this was eventually ended. Now the kids have to stay in the school. But I can't recall if any kids took food to the library. It was fun the first year, going to the grocery store next door and getting a candy bar and pop for lunch, but that eventually got old and my friends and I fell into a routine of eating in the cafeteria and then finishing the lunchtime sitting in the gym or a hallway and talking.
This was also done at the local high school in my town when I was in elementary school. I'd hear the older kids talk about it on bus rides home. We were in a small town so the bus I was on had students of all ages and it would drop us all off at the different schools. I was always jealous the older kids got to go have lunch at McDonald's. I moved to a new state for my jr high year and that local high school didn't allow it. But, my husband's high school did which was a few towns over.
It wasn't really allowed at my school but the teacher usually looked the other way if you quiet about it. I would often sneak in a sandwich when I was doing homework or studying for a test.
When I was in grade school I walked with siblings about half a mile to school, walked home for lunch, walked back to school, and walked home after school, and sometimes walked to the local library and then home.
When I was in 6th grade we moved next door to the grade school in another town. The junior high and high school was across a street from the grade school, so I continued to go home for lunch, eating in the high school cafeteria only about once. I don't remember if I ever asked for permission to go home for lunch, but I went home for lunch every day for a long time and don't remember getting into trouble about it.
Naturally I never ate lunch in any school library and don't know if that was permitted. As for using the library, as far as I remember any student could use the high school library if it was open and if the student wasn't supposed to be be someplace else.
Where my grandparents lived kids were able to walk home for lunch which I always found interesting. I was good friends with their neighbors who had kids my age. The school was within a short walking distance so it didn't take long at all to walk home for lunch. I thought that was pretty cool.