And know that our teacher, the Beit Yosef, wrote in section 1 that the prohibition to recite opposite a beit hakise—this is specifically when it does not have partitions. But if it has partitions, even if there is excrement within it—one may recite opposite it nearby and need not be concerned, provided that a foul odor does not reach him. Thus far his words. And many poskim agreed with him (the Levush and the Bach and the Ma'adanei Yom Tov), but they required that the partitions be ten tefachim high. However, the commentators of the Shulchan Aruch disagreed with him, and wrote that certainly all the battei hakise that were in the time of the Shas had partitions, as the Tosafot wrote in Sukkah (36b). And if so, when they said that it is prohibited opposite a beit hakise, it means even when it has partitions. And the reason for the matter: for partitions that were made for the sake of a beit hakise—their law is like the beit hakise itself. And one requires another partition outside the partitions of the beit hakise, or that the partition was made for the sake of a house, except that they supported a beit hakise against it from the other side, for then it is permitted to recite and to pray opposite this partition (Taz, and the Magen Avraham is somewhat uncertain in this, see there). And behold, even according to this view, in the railroads where they sit in the wagons, and in front of him there is a beit hakise where one of the walls of the wagon serves also for the beit hakise, it is permitted simply to pray and to recite and to bless opposite it. (For even the Taz permits in such a case, and the Magen Avraham even regarding the primary ruling of the Beit Yosef is as one who is uncertain, for he wrote: and one who is lenient should see that at any rate they should be ten high. Thus far his words, see there.)
ודע שרבינו הבית יוסף כתב בסעיף א דהאיסור לקרות כנגד בית הכסא – זהו דווקא כשאין לו מחיצות. אבל אם יש לו מחיצות, אפילו יש בו צואה – קורא כנגדו בסמוך ואינו חושש, אם רק אינו מגיע לו ריח רע. עד כאן לשונו. והסכימו לו הרבה פוסקים (הלבוש והב"ח והמעדני יום טוב), אך הצריכו שהמחיצות יהיה גובהן עשרה טפחים. אך מפרשי השולחן ערוך חלקו עליו, וכתבו דוודאי כל הבית הכסאות שבזמן הש"ס היה להם מחיצות, כמו שכתבו התוספות בסוכה (לו ב). ואם כן כשאמרו דאסור נגד בית הכסא, היינו אפילו ביש לו מחיצות. וטעם הדבר: דמחיצות שנעשו לשם בית הכסא – דינן כהבית הכסא עצמו. וצריך מחיצה אחרת מחוץ למחיצות בית הכסא, או שהמחיצה נעשית לשם בית. אלא שהסמיכו לו מצד האחר בית הכסא, דאז מותר לקרות ולהתפלל נגד מחיצה זו (ט"ז, והמגן אברהם כמסתפק קצת בזה, עיין שם). והנה אפילו לדעה זו, במסילות הברזל שיושבים בהוואגאנען, ומלפניו יש בית הכסא שאחד מכותלי הוואגאן משמש גם להבית הכסא, דמותר בפשיטות להתפלל ולקרות ולברך כנגדו. (שהרי גם ט"ז מתיר בכהאי גוונא, והמגן אברהם גם בעיקר הדין של הבית יוסף כמסתפק, שהרי כתב: והמיקל יראה שעל כל פנים יהיו גבוהות עשרה. עד כאן לשונו, עיין שם.)